@@ -232,8 +232,8 @@ func (s *StatusSyncer) updateNodeStatus(ctx context.Context, cli client.Client,
232232 // update apiv1alpha1.NodeConditionReadOnly.
233233 s .updateNodeCondition (node , int (apiv1alpha1 .IndexReadOnly ), isReadOnly )
234234
235- if err = s .setPodHealthy (ctx , & pod , node ); err != nil {
236- log .Error (err , "cannot update pod " , "name " , podName , "namespace" , pod .Namespace )
235+ if err = s .updatePodLabel (ctx , & pod , node ); err != nil {
236+ log .Error (err , "failed to update labels " , "pod " , pod . Name , "namespace" , pod .Namespace )
237237 }
238238 }
239239
@@ -358,9 +358,10 @@ func (s *StatusSyncer) addNodesInXenon(host string, toAdd []string) error {
358358 return nil
359359}
360360
361- // setPodHealthy set the pod lable healthy .
362- func (s * StatusSyncer ) setPodHealthy (ctx context.Context , pod * corev1.Pod , node * apiv1alpha1.NodeStatus ) error {
361+ // updatePodLabel update the pod lables .
362+ func (s * StatusSyncer ) updatePodLabel (ctx context.Context , pod * corev1.Pod , node * apiv1alpha1.NodeStatus ) error {
363363 healthy := "no"
364+ isPodLabelsUpdated := false
364365 if node .Conditions [apiv1alpha1 .IndexLagged ].Status == corev1 .ConditionFalse {
365366 if node .Conditions [apiv1alpha1 .IndexLeader ].Status == corev1 .ConditionFalse &&
366367 node .Conditions [apiv1alpha1 .IndexReadOnly ].Status == corev1 .ConditionTrue &&
@@ -375,6 +376,13 @@ func (s *StatusSyncer) setPodHealthy(ctx context.Context, pod *corev1.Pod, node
375376
376377 if pod .Labels ["healthy" ] != healthy {
377378 pod .Labels ["healthy" ] = healthy
379+ isPodLabelsUpdated = true
380+ }
381+ if pod .Labels ["role" ] != node .RaftStatus .Role {
382+ pod .Labels ["role" ] = node .RaftStatus .Role
383+ isPodLabelsUpdated = true
384+ }
385+ if isPodLabelsUpdated {
378386 if err := s .cli .Update (ctx , pod ); client .IgnoreNotFound (err ) != nil {
379387 return err
380388 }
0 commit comments