@@ -352,15 +352,17 @@ def _update_history(self, cluster: Cluster):
352352 if isinstance (cluster .history .lines [0 ], dict ):
353353 history_state = cluster .history .lines [0 ]
354354 if history_state .get ('last_leader' ) != self .name : # pyright: ignore [reportUnknownMemberType]
355- new_state = (history_state .get ('switches' , 0 ) + 1 , 0 , '' , self .name ) # noqa: E501 # pyright: ignore [reportUnknownMemberType, reportUnknownVariableType]
356- self .dcs .set_history_value (json .dumps (new_state )) # FIXME: append instead
355+ state = [(history_state .get ('switches' , 0 ), 0 , '' , history_state .get ('last_leader' ))] # noqa: E501 # pyright: ignore [reportUnknownMemberType, reportUnknownVariableType]
356+ state .append ((history_state .get ('switches' , 0 ) + 1 , 0 , '' , self .name )) # noqa: E501 # pyright: ignore [reportUnknownMemberType, reportUnknownVariableType]
357+ self .dcs .set_history_value (json .dumps (state ))
357358 else :
358359 history_state = cluster .history .lines [- 1 ]
359360 if len (history_state ) > 3 and history_state [3 ] != self .name :
360361 new_state = (history_state [0 ] + 1 , 0 , '' , self .name )
361- self .dcs .set_history_value (json .dumps (cluster .history .lines .append (new_state )))
362+ cluster .history .lines .append (new_state )
363+ self .dcs .set_history_value (json .dumps (cluster .history .lines ))
362364 else : # no history yet, set initial item
363- self .dcs .set_history_value (json .dumps ([(0 , 0 , '' , self .name )])) # FIXME: append to list instead
365+ self .dcs .set_history_value (json .dumps ([(0 , 0 , '' , self .name )]))
364366
365367 def _check_for_failover (self , cluster : Cluster ):
366368 if cluster .failover and cluster .failover .target_site :
0 commit comments