@@ -232,8 +232,8 @@ func (s *StatusSyncer) updateNodeStatus(ctx context.Context, cli client.Client,
232
232
// update apiv1alpha1.NodeConditionReadOnly.
233
233
s .updateNodeCondition (node , int (apiv1alpha1 .IndexReadOnly ), isReadOnly )
234
234
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 )
237
237
}
238
238
}
239
239
@@ -358,9 +358,10 @@ func (s *StatusSyncer) addNodesInXenon(host string, toAdd []string) error {
358
358
return nil
359
359
}
360
360
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 {
363
363
healthy := "no"
364
+ isPodLabelsUpdated := false
364
365
if node .Conditions [apiv1alpha1 .IndexLagged ].Status == corev1 .ConditionFalse {
365
366
if node .Conditions [apiv1alpha1 .IndexLeader ].Status == corev1 .ConditionFalse &&
366
367
node .Conditions [apiv1alpha1 .IndexReadOnly ].Status == corev1 .ConditionTrue &&
@@ -375,6 +376,13 @@ func (s *StatusSyncer) setPodHealthy(ctx context.Context, pod *corev1.Pod, node
375
376
376
377
if pod .Labels ["healthy" ] != healthy {
377
378
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 {
378
386
if err := s .cli .Update (ctx , pod ); client .IgnoreNotFound (err ) != nil {
379
387
return err
380
388
}
0 commit comments