-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
KEP-4818: Allow zero value for Sleep Action of PreStop Hook #4855
KEP-4818: Allow zero value for Sleep Action of PreStop Hook #4855
Conversation
sreeram-venkitesh
commented
Sep 16, 2024
- One-line PR description: Added the kep.yaml files and the initial readme file for KEP 4818.
- Issue link: Allow zero value for Sleep Action of PreStop Hook #4818
- Other comments: Discussion doc
/cc |
keps/sig-node/4818-allow-zero-value-for-sleep-action-of-prestop-hook/README.md
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will need a PRR file also.
keps/sig-node/4818-allow-zero-value-for-sleep-action-of-prestop-hook/README.md
Show resolved
Hide resolved
keps/sig-node/4818-allow-zero-value-for-sleep-action-of-prestop-hook/README.md
Show resolved
Hide resolved
|
||
The Sleep action is implemented with the time package from Go’s standard library. The `time.After()` which is used to implement the sleep permits a zero sleep duration. A negative or a zero sleep duration will cause the function to return immediately and function like a no-op. | ||
|
||
The implementation in KEP 3960 supports only non-zero values for the sleep duration. It is semantically correct to support a zero value for this field since time.After() also supports zero and negative durations. Negative values as well as zero have the same effect with time.After(), they both return immediately. We don’t need to support negative values since they have the same effect as setting the duration to zero. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please expand on whether kubelet accepts 0
today and it is only API server validaiton or kubelet also validates the value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, kubelet accepts 0
. No validation is done at the kubelet level. The feature gate for PodLifecycleSleepAction
is used inside runSleepHandler
function and it returns nil if the feature is disabled. We can do a similar check at the kubelet level but it doesn't really make sense since a sleep of zero seconds would be similar to returning nil
right? Since the logic in kubelet already supports zero value (time.After(0)
), I feel that we don't need the feature gate in kubelet. Also the feature gate check for PodLifecycleSleepAction
would be removed in v1.32 since its planning to graduate to stable. Please let me know what you think!
Relevant function in kubelet's lifecyle/handlers.go
func (hr *handlerRunner) runSleepHandler(ctx context.Context, seconds int64) error {
if !utilfeature.DefaultFeatureGate.Enabled(features.PodLifecycleSleepAction) {
return nil
}
c := time.After(time.Duration(seconds) * time.Second)
select {
case <-ctx.Done():
// unexpected termination
return fmt.Errorf("container terminated before sleep hook finished")
case <-c:
return nil
}
}
keps/sig-node/4818-allow-zero-value-for-sleep-action-of-prestop-hook/README.md
Outdated
Show resolved
Hide resolved
keps/sig-node/4818-allow-zero-value-for-sleep-action-of-prestop-hook/README.md
Outdated
Show resolved
Hide resolved
keps/sig-node/4818-allow-zero-value-for-sleep-action-of-prestop-hook/kep.yaml
Outdated
Show resolved
Hide resolved
Addressed all the above comments, please let me know if there are any more tests that I can add! |
keps/sig-node/4818-allow-zero-value-for-sleep-action-of-prestop-hook/README.md
Outdated
Show resolved
Hide resolved
@SergeyKanzhelev @kannon92 Thank you so much! I've resolved the comments and added you two as approver and reviewer. I still need to add the PRR approver, but I first pinged wojtek-t (who is the PRR approver for KEP 3960) in Slack to confirm with him first that I can add him as the PRR approver for this KEP too. I will update this field once he confirms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
You still need PRR approver to be listed in 4818.yaml
@SergeyKanzhelev I've added wojtek as the PRR approver. Please approve the PR again since there are new changes. Thanks a lot! |
/lgtm |
/assign @wojtek-t |
@SergeyKanzhelev I don't think your owner file worked here. @mrunalp @dchen1107 can you help here? |
Yes, it will start working once merged. Also we need @wojtek-t 's PRR review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment - other than that LGTM from PRR perspective.
keps/sig-node/4818-allow-zero-value-for-sleep-action-of-prestop-hook/README.md
Outdated
Show resolved
Hide resolved
keps/sig-node/4818-allow-zero-value-for-sleep-action-of-prestop-hook/README.md
Show resolved
Hide resolved
keps/sig-node/4818-allow-zero-value-for-sleep-action-of-prestop-hook/README.md
Outdated
Show resolved
Hide resolved
@wojtek-t: I've fixed the section on downgrading, I missed that earlier! Thanks for catching it. For #4855 (comment), I've added a line mentioning this test case under the list of unit tests planned to be implemented in alpha. @pacoxu: I've updated the validation error message to mention the feature gate. Will update this in kubernetes/kubernetes#127094. Please take a look! Thanks folks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/lgtm |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mrunalp, SergeyKanzhelev, sreeram-venkitesh, wojtek-t 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 |