Skip to content

Commit 306a51f

Browse files
authored
Merge pull request radondb#512 from runkecheng/fix_pod_labels
syncer: failed to patch pod labels.
2 parents a67fe48 + 303aba0 commit 306a51f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mysqlcluster/syncer/status.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ func (s *StatusSyncer) addNodesInXenon(host string, toAdd []string) error {
413413

414414
// updatePodLabel update the pod lables.
415415
func (s *StatusSyncer) updatePodLabel(ctx context.Context, pod *corev1.Pod, node *apiv1alpha1.NodeStatus) error {
416+
oldPod := pod.DeepCopy()
416417
healthy := "no"
417418
isPodLabelsUpdated := false
418419
if node.Conditions[apiv1alpha1.IndexLagged].Status == corev1.ConditionFalse {
@@ -440,7 +441,7 @@ func (s *StatusSyncer) updatePodLabel(ctx context.Context, pod *corev1.Pod, node
440441
isPodLabelsUpdated = true
441442
}
442443
if isPodLabelsUpdated {
443-
if err := s.cli.Patch(ctx, pod, client.MergeFrom(pod)); client.IgnoreNotFound(err) != nil {
444+
if err := s.cli.Patch(ctx, pod, client.MergeFrom(oldPod)); client.IgnoreNotFound(err) != nil {
444445
return err
445446
}
446447
}

0 commit comments

Comments
 (0)