From 321686d1605b2f8bcfda0018a5e927d449aca79a Mon Sep 17 00:00:00 2001 From: chenpeicheng9 <69852457+chenpeicheng9@users.noreply.github.com> Date: Tue, 23 Jan 2024 19:28:12 +0800 Subject: [PATCH] Revert "the CloneSet pod lifecycle can be transformed to Normal only if ContainerReady is true" This reverts commit 3ccb6a22db949160ef5823d517e8cb2838107738. --- apis/apps/pub/lifecycle.go | 2 +- pkg/controller/cloneset/sync/cloneset_update.go | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/apis/apps/pub/lifecycle.go b/apis/apps/pub/lifecycle.go index 1f14f8149e..44aec77572 100644 --- a/apis/apps/pub/lifecycle.go +++ b/apis/apps/pub/lifecycle.go @@ -32,7 +32,7 @@ const ( // It will translate to Updated state if the in-place update of the Pod is done. LifecycleStateUpdating LifecycleStateType = "Updating" // LifecycleStateUpdated means the Pod is updated, but unavailable. - // It will translate to Normal state if Lifecycle.InPlaceUpdate is hooked and pod condition ContainerReady is true. + // It will translate to Normal state if Lifecycle.InPlaceUpdate is hooked. LifecycleStateUpdated LifecycleStateType = "Updated" // LifecycleStatePreparingDelete means the Pod is prepared to delete. // The Pod will be deleted by workload if Lifecycle.PreDelete is Not hooked. diff --git a/pkg/controller/cloneset/sync/cloneset_update.go b/pkg/controller/cloneset/sync/cloneset_update.go index 1675f6fea9..a3e1cc7343 100644 --- a/pkg/controller/cloneset/sync/cloneset_update.go +++ b/pkg/controller/cloneset/sync/cloneset_update.go @@ -183,22 +183,24 @@ func (c *realControl) refreshPodState(cs *appsv1alpha1.CloneSet, coreControl clo // then rollback, do not need update pod inplace since it is the update revision, // so just update pod lifecycle state. ref: https://github.com/openkruise/kruise/issues/1156 if clonesetutils.EqualToRevisionHash("", pod, updateRevision) { - if util.IsRunningAndContainerReady(pod) && lifecycle.IsInPlaceUpdateHookNilOrAllHooked(cs.Spec.Lifecycle, pod) { - state = appspub.LifecycleStateNormal - } else { + if cs.Spec.Lifecycle != nil && !lifecycle.IsPodAllHooked(cs.Spec.Lifecycle.InPlaceUpdate, pod) { state = appspub.LifecycleStateUpdated + } else { + state = appspub.LifecycleStateNormal } } case appspub.LifecycleStateUpdating: if opts.CheckPodUpdateCompleted(pod) == nil { - if util.IsRunningAndContainerReady(pod) && lifecycle.IsInPlaceUpdateHookNilOrAllHooked(cs.Spec.Lifecycle, pod) { - state = appspub.LifecycleStateNormal - } else { + if cs.Spec.Lifecycle != nil && !lifecycle.IsPodAllHooked(cs.Spec.Lifecycle.InPlaceUpdate, pod) { state = appspub.LifecycleStateUpdated + } else { + state = appspub.LifecycleStateNormal } } case appspub.LifecycleStateUpdated: - if util.IsRunningAndContainerReady(pod) && lifecycle.IsInPlaceUpdateHookNilOrAllHooked(cs.Spec.Lifecycle, pod) { + if cs.Spec.Lifecycle == nil || + cs.Spec.Lifecycle.InPlaceUpdate == nil || + lifecycle.IsPodAllHooked(cs.Spec.Lifecycle.InPlaceUpdate, pod) { state = appspub.LifecycleStateNormal } }