Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mark pod not ready feature to Lifecycle hooks #979

Merged
merged 1 commit into from
May 20, 2022

Conversation

veophi
Copy link
Member

@veophi veophi commented May 18, 2022

Signed-off-by: mingzhou.swx mingzhou.swx@alibaba-inc.com

Ⅰ. Describe what this PR does

  • Add mark pod not ready feature to Lifecycle hooks;
  • CloneSet status.availableReplicas consider lifecycle state, only the pods at normal state are available.

Ⅱ. Does this pull request fix one issue?

#944

@kruise-bot kruise-bot requested review from FillZpp and shiyan2016 May 18, 2022 08:16
@kruise-bot kruise-bot added the size/L size/L: 100-499 label May 18, 2022
pkg/util/lifecycle/lifecycle_utils.go Outdated Show resolved Hide resolved
pkg/util/podreadiness/pod_readiness_utils.go Outdated Show resolved Hide resolved
pkg/controller/containerrecreaterequest/crr_controller.go Outdated Show resolved Hide resolved
pkg/util/lifecycle/lifecycle_utils.go Outdated Show resolved Hide resolved
pkg/util/inplaceupdate/inplace_update.go Outdated Show resolved Hide resolved
@veophi veophi force-pushed the lifecycle-notready branch from 906d86d to e06c854 Compare May 18, 2022 15:40
// Actually, there is a bug cased by this transformation from PreparingDelete to Normal,
// i.e., Lifecycle Updated Hook may be lost if the pod was transformed from Updating state
// to PreparingDelete.
if cs.Spec.Lifecycle != nil || lifecycle.IsHookRequiredPodNotReady(cs.Spec.Lifecycle.PreDelete) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opt.semgrep.bad-nil-guard: Useless nil guard

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@veophi veophi force-pushed the lifecycle-notready branch from e06c854 to 39f9303 Compare May 19, 2022 02:19
@codecov-commenter
Copy link

codecov-commenter commented May 19, 2022

Codecov Report

Merging #979 (8fa6413) into master (cf95157) will increase coverage by 0.01%.
The diff coverage is 58.82%.

@@            Coverage Diff             @@
##           master     #979      +/-   ##
==========================================
+ Coverage   49.93%   49.95%   +0.01%     
==========================================
  Files         120      121       +1     
  Lines       11558    11579      +21     
==========================================
+ Hits         5772     5784      +12     
- Misses       4914     4924      +10     
+ Partials      872      871       -1     
Flag Coverage Δ
unittests 49.95% <58.82%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/controller/cloneset/sync/cloneset_scale.go 25.74% <0.00%> (-0.39%) ⬇️
pkg/controller/daemonset/daemonset_controller.go 41.80% <0.00%> (-0.09%) ⬇️
pkg/controller/cloneset/sync/cloneset_update.go 47.29% <25.00%> (-0.96%) ⬇️
pkg/controller/statefulset/stateful_set_control.go 61.89% <50.00%> (+0.18%) ⬆️
...kg/controller/cloneset/sync/cloneset_sync_utils.go 87.03% <66.66%> (ø)
pkg/util/podreadiness/pod_readiness_utils.go 77.38% <76.00%> (+0.27%) ⬆️
pkg/util/podreadiness/pod_readiness.go 84.61% <84.61%> (ø)
pkg/controller/cloneset/cloneset_status.go 90.47% <100.00%> (ø)
...roller/uniteddeployment/uniteddeployment_update.go 72.28% <0.00%> (-1.87%) ⬇️
pkg/controller/uniteddeployment/revision.go 67.93% <0.00%> (+1.52%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf95157...8fa6413. Read the comment docs.

@veophi veophi force-pushed the lifecycle-notready branch from 39f9303 to 7a778df Compare May 19, 2022 02:31
return &ReconcileContainerRecreateRequest{
Client: util.NewClientFromManager(mgr, "containerrecreaterequest-controller"),
Client: cli,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gofmt: File is not gofmt-ed with -s

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

// Interface for managing pods lifecycle.
type Interface interface {
UpdatePodLifecycle(pod *v1.Pod, state appspub.LifecycleStateType) (bool, *v1.Pod, error)
UpdatePodLifecycle(pod *v1.Pod, state appspub.LifecycleStateType, requiredPodNotReady bool) (bool, *v1.Pod, error)
UpdatePodLifecycleWithHandler(pod *v1.Pod, state appspub.LifecycleStateType, inPlaceUpdateHandler *appspub.LifecycleHook) (bool, *v1.Pod, error)
}

type realControl struct {
adp podadapter.Adapter
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gofmt: File is not gofmt-ed with -s

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

// Actually, there is a bug cased by this transformation from PreparingDelete to Normal,
// i.e., Lifecycle Updated Hook may be lost if the pod was transformed from Updating state
// to PreparingDelete.
if cs.Spec.Lifecycle != nil && (
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gofmt: File is not gofmt-ed with -s

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@veophi veophi force-pushed the lifecycle-notready branch from 7a778df to 7f9b557 Compare May 19, 2022 05:46
@@ -755,7 +755,8 @@ func (dsc *ReconcileDaemonSet) syncWithPreparingDelete(ds *appsv1alpha1.DaemonSe
podsCanDelete = append(podsCanDelete, podName)
continue
}
if updated, gotPod, err := dsc.lifecycleControl.UpdatePodLifecycle(pod, appspub.LifecycleStatePreparingDelete); err != nil {
requiredPodNotReady := ds.Spec.Lifecycle.PreDelete.MarkPodNotReady
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rename all requiredPodNotReady variables/comments to markPodNotReady

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@veophi veophi force-pushed the lifecycle-notready branch 2 times, most recently from c57492b to 3b67a4f Compare May 19, 2022 09:38
@furykerry
Copy link
Member

/lgtm

Signed-off-by: mingzhou.swx <mingzhou.swx@alibaba-inc.com>
@veophi veophi force-pushed the lifecycle-notready branch from f959515 to 8fa6413 Compare May 20, 2022 04:00
Copy link
Member

@FillZpp FillZpp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FillZpp

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kruise-bot kruise-bot merged commit 2fd19a4 into openkruise:master May 20, 2022
diannaowa pushed a commit to diannaowa/kruise that referenced this pull request Sep 14, 2022
Signed-off-by: mingzhou.swx <mingzhou.swx@alibaba-inc.com>

Co-authored-by: mingzhou.swx <mingzhou.swx@alibaba-inc.com>
Signed-off-by: Liu Zhenwei <zwliu@thoughtworks.com>
ppbits pushed a commit to ppbits/kruise that referenced this pull request Apr 4, 2024
Co-authored-by: mingzhou.swx <mingzhou.swx@alibaba-inc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants