From f6f844118d3203e60e9fb85b0ae03f03b2451d74 Mon Sep 17 00:00:00 2001 From: acekingke Date: Mon, 2 Aug 2021 15:34:58 +0800 Subject: [PATCH 1/2] cluster: fix the bug of unchange when the status is't updated. #158 --- cluster/syncer/statefulset.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cluster/syncer/statefulset.go b/cluster/syncer/statefulset.go index 50d72660..544ca15e 100644 --- a/cluster/syncer/statefulset.go +++ b/cluster/syncer/statefulset.go @@ -185,8 +185,7 @@ func (s *StatefulSetSyncer) updatePod(ctx context.Context) error { log.Info("statefulSet was changed, run update") if s.sfs.Status.ReadyReplicas < s.sfs.Status.Replicas { - log.Info("can't start/continue 'update': waiting for all replicas are ready") - return nil + return fmt.Errorf("can't start/continue 'update': waiting for all replicas are ready") } pods := corev1.PodList{} From e8207825b4ff3a331486d3ab3c8449fa2cd6289b Mon Sep 17 00:00:00 2001 From: acekingke Date: Tue, 3 Aug 2021 09:32:41 +0800 Subject: [PATCH 2/2] cluster: fix the bug about status #158 --- cluster/syncer/statefulset.go | 3 ++- cluster/syncer/status.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cluster/syncer/statefulset.go b/cluster/syncer/statefulset.go index 544ca15e..50d72660 100644 --- a/cluster/syncer/statefulset.go +++ b/cluster/syncer/statefulset.go @@ -185,7 +185,8 @@ func (s *StatefulSetSyncer) updatePod(ctx context.Context) error { log.Info("statefulSet was changed, run update") if s.sfs.Status.ReadyReplicas < s.sfs.Status.Replicas { - return fmt.Errorf("can't start/continue 'update': waiting for all replicas are ready") + log.Info("can't start/continue 'update': waiting for all replicas are ready") + return nil } pods := corev1.PodList{} diff --git a/cluster/syncer/status.go b/cluster/syncer/status.go index 02df3904..06ede056 100644 --- a/cluster/syncer/status.go +++ b/cluster/syncer/status.go @@ -226,7 +226,9 @@ func (s *StatusSyncer) updateNodeStatus(ctx context.Context, cli client.Client, log.Error(err, "cannot update pod", "name", podName, "namespace", pod.Namespace) } } - + if len(pods) != int(*s.Spec.Replicas) { + return fmt.Errorf("not all replicas do something") + } return nil }