Skip to content

Commit

Permalink
Revert "the CloneSet pod lifecycle can be transformed to Normal only …
Browse files Browse the repository at this point in the history
…if ContainerReady is true"

This reverts commit 3ccb6a2.
  • Loading branch information
chenpeicheng9 committed Jan 23, 2024
1 parent 3ccb6a2 commit 321686d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apis/apps/pub/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 9 additions & 7 deletions pkg/controller/cloneset/sync/cloneset_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 321686d

Please sign in to comment.