From ed3b1f3c62eb9df1d56ac2d34e6682c9e7853374 Mon Sep 17 00:00:00 2001 From: acekingke Date: Wed, 4 Aug 2021 09:17:27 +0800 Subject: [PATCH 1/3] cluster: fix the bug change yaml will happen nothing #158 --- cluster/syncer/statefulset.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cluster/syncer/statefulset.go b/cluster/syncer/statefulset.go index 50d72660..5d845732 100644 --- a/cluster/syncer/statefulset.go +++ b/cluster/syncer/statefulset.go @@ -457,7 +457,15 @@ func (s *StatefulSetSyncer) applyNWait(ctx context.Context, pod *corev1.Pod) err if err != nil && !k8serrors.IsNotFound(err) { return false, err } + ordinal, err := utils.GetOrdinal(pod.Name) + if err != nil { + return false, err + } + if ordinal >= int(*s.Spec.Replicas) { + log.Info("retry waiting pod", "pod", pod.Name) + return true, nil + } if pod.Status.Phase == corev1.PodFailed { return false, fmt.Errorf("pod %s is in failed phase", pod.Name) } From 4a6f33a76213ee562e8a9c2603f5d6b7df026831 Mon Sep 17 00:00:00 2001 From: acekingke Date: Wed, 4 Aug 2021 10:26:36 +0800 Subject: [PATCH 2/3] cluster: format the code #158 --- cluster/syncer/statefulset.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cluster/syncer/statefulset.go b/cluster/syncer/statefulset.go index 5d845732..e52bd47f 100644 --- a/cluster/syncer/statefulset.go +++ b/cluster/syncer/statefulset.go @@ -457,15 +457,16 @@ func (s *StatefulSetSyncer) applyNWait(ctx context.Context, pod *corev1.Pod) err if err != nil && !k8serrors.IsNotFound(err) { return false, err } + ordinal, err := utils.GetOrdinal(pod.Name) if err != nil { return false, err } - if ordinal >= int(*s.Spec.Replicas) { log.Info("retry waiting pod", "pod", pod.Name) return true, nil } + if pod.Status.Phase == corev1.PodFailed { return false, fmt.Errorf("pod %s is in failed phase", pod.Name) } From 64a2ff702ed8144b6431cdf87c84962ef278a5e4 Mon Sep 17 00:00:00 2001 From: acekingke Date: Wed, 4 Aug 2021 11:36:27 +0800 Subject: [PATCH 3/3] cluster: change the log info #158 --- cluster/syncer/statefulset.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster/syncer/statefulset.go b/cluster/syncer/statefulset.go index e52bd47f..4f0b8df2 100644 --- a/cluster/syncer/statefulset.go +++ b/cluster/syncer/statefulset.go @@ -463,7 +463,7 @@ func (s *StatefulSetSyncer) applyNWait(ctx context.Context, pod *corev1.Pod) err return false, err } if ordinal >= int(*s.Spec.Replicas) { - log.Info("retry waiting pod", "pod", pod.Name) + log.Info("replicas were changed, should skip", "pod", pod.Name) return true, nil }