From 0da21a091bb1dd4d578921f8d9e8fff4a47fdc32 Mon Sep 17 00:00:00 2001 From: free6om Date: Thu, 7 Nov 2024 14:07:46 +0800 Subject: [PATCH] fix: lost event during image rolling update (#8424) --- pkg/controller/instanceset/reconciler_update.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/controller/instanceset/reconciler_update.go b/pkg/controller/instanceset/reconciler_update.go index 53b6b58c671..b80bb87cfad 100644 --- a/pkg/controller/instanceset/reconciler_update.go +++ b/pkg/controller/instanceset/reconciler_update.go @@ -21,6 +21,7 @@ package instanceset import ( "fmt" + "time" apps "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -120,6 +121,7 @@ func (r *updateReconciler) Reconcile(tree *kubebuilderx.ObjectTree) (kubebuilder updatedPods := 0 priorities := ComposeRolePriorityMap(its.Spec.Roles) isBlocked := false + needRetry := false sortObjects(oldPodList, priorities, false) for _, pod := range oldPodList { if updatingPods >= updateCount || updatingPods >= unavailable { @@ -135,6 +137,8 @@ func (r *updateReconciler) Reconcile(tree *kubebuilderx.ObjectTree) (kubebuilder } if !isContainersAvailable(pod, its.Spec.MinReadySeconds) { tree.Logger.Info(fmt.Sprintf("InstanceSet %s/%s blocks on update as some the container(s) of pod %s are not started at least for %d seconds", its.Namespace, its.Name, pod.Name, its.Spec.MinReadySeconds)) + // as no further event triggers the next reconciliation, we need a retry + needRetry = true break } if !isHealthy(pod) { @@ -187,6 +191,9 @@ func (r *updateReconciler) Reconcile(tree *kubebuilderx.ObjectTree) (kubebuilder if !isBlocked { meta.RemoveStatusCondition(&its.Status.Conditions, string(workloads.InstanceUpdateRestricted)) } + if needRetry { + return kubebuilderx.RetryAfter(2 * time.Second), nil + } return kubebuilderx.Continue, nil }