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

Clean up termination config/defaults #1685

Merged
merged 5 commits into from
Oct 21, 2022

Conversation

severinson
Copy link
Contributor

For pods that set no grace period or explicitly set it to zero, automatically change it to the minimum allowed. Remove the default grace period setting and instead use the minimum as the default.

server.schedulingConfig.MinTerminationGracePeriod.Seconds(),
)
if defaultTerminationGracePeriodSeconds < 0 {
panic("MinTerminationGracePeriod is negative")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not panic here- if we want to validate config let's do it at startup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Let's remove the panic and later add proper config validation at startup.

spec.TerminationGracePeriodSeconds = &defaultTerminationGracePeriod
var podTerminationGracePeriodSeconds int64
if spec.TerminationGracePeriodSeconds != nil {
podTerminationGracePeriodSeconds = *spec.TerminationGracePeriodSeconds
Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't verify that *spec.TerminationGracePeriodSeconds is > 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have another check that rejects pods with a value less than min.

podTerminationGracePeriodSeconds = *spec.TerminationGracePeriodSeconds
}
if podTerminationGracePeriodSeconds == 0 {
defaultTerminationGracePeriodSeconds := int64(
Copy link
Collaborator

Choose a reason for hiding this comment

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

why don't we do the conversion once at startup rather than every time? Or even make the config value be an int representing seconds rather than a duration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is fine. I like having a duration. Since then we can put things like "5m".

d80tb7
d80tb7 previously approved these changes Oct 21, 2022
@severinson severinson merged commit 3126964 into master Oct 21, 2022
@severinson severinson deleted the severinson/graceful-termination branch October 21, 2022 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants