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

KEP-4818: Allow zero value for Sleep Action of PreStop Hook #4855

Conversation

sreeram-venkitesh
Copy link
Member

  • One-line PR description: Added the kep.yaml files and the initial readme file for KEP 4818.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory sig/node Categorizes an issue or PR as relevant to SIG Node. labels Sep 16, 2024
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 16, 2024
@kannon92
Copy link
Contributor

/cc

Copy link
Contributor

@kannon92 kannon92 left a 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.


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.
Copy link
Member

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?

Copy link
Member Author

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
	}
}

@sreeram-venkitesh
Copy link
Member Author

Addressed all the above comments, please let me know if there are any more tests that I can add!

@sreeram-venkitesh
Copy link
Member Author

@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.

Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a 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

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 24, 2024
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 24, 2024
@sreeram-venkitesh
Copy link
Member Author

sreeram-venkitesh commented Sep 24, 2024

@SergeyKanzhelev I've added wojtek as the PRR approver. Please approve the PR again since there are new changes. Thanks a lot!

@SergeyKanzhelev
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 24, 2024
@SergeyKanzhelev
Copy link
Member

/assign @wojtek-t

@kannon92
Copy link
Contributor

@SergeyKanzhelev I don't think your owner file worked here.

@mrunalp @dchen1107 can you help here?

@SergeyKanzhelev
Copy link
Member

@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

Copy link
Member

@wojtek-t wojtek-t left a 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.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 1, 2024
@sreeram-venkitesh
Copy link
Member Author

@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!

Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 1, 2024
@pacoxu
Copy link
Member

pacoxu commented Oct 1, 2024

/lgtm

@wojtek-t
Copy link
Member

wojtek-t commented Oct 3, 2024

/lgtm
/approve PRR

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 3, 2024
@k8s-ci-robot k8s-ci-robot merged commit 48f928a into kubernetes:master Oct 3, 2024
3 of 4 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.32 milestone Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/node Categorizes an issue or PR as relevant to SIG Node. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Development

Successfully merging this pull request may close these issues.

7 participants