-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Adding termination grace period to Deployment, RC, RCSet, and Job #82170
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
test/utils/runners.go
Outdated
@@ -321,7 +322,8 @@ func (config *DeploymentConfig) create() error { | |||
Annotations: config.Annotations, | |||
}, | |||
Spec: v1.PodSpec{ | |||
Affinity: config.Affinity, | |||
Affinity: config.Affinity, | |||
TerminationGracePeriodSeconds: func(i int) *int64 { x := int64(math.Max(float64(i), 1)); return &x }(config.TerminationGracePeriodSeconds), |
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.
i think it's better to not use an anonymous function and instead define it in the runners.go level for all create() methods to use.
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.
Shouldn't the default be whatever the k8s default is and not 1?
Why do we even need any function (other than Max)? Maybe we could use https://github.com/kubernetes/utils/blob/master/integer/integer.go#L20?
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.
@neolit123 Thanks for the quick review. Made the change.
@MaciekPytel The default that was being used for RCConfig was 1, so kept that.
The file already uses math.Max for ints so kept that too.
test/utils/runners.go
Outdated
@@ -569,7 +573,6 @@ func (config *RCConfig) create() error { | |||
if config.DNSPolicy == nil { | |||
config.DNSPolicy = &dnsDefault | |||
} | |||
one := int64(1) |
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.
Where is this default now?
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.
Added a default field now.
test/utils/runners.go
Outdated
@@ -1537,6 +1540,11 @@ func attachConfigMaps(template *v1.PodTemplateSpec, configMapNames []string) { | |||
template.Spec.Containers[0].VolumeMounts = mounts | |||
} | |||
|
|||
func (config *RCConfig) getTerminationGracePeriodSeconds() *int64 { | |||
x := int64(math.Max(float64(config.TerminationGracePeriodSeconds), 1)) |
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.
What if someone sets it explicitly to 0?
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.
Fixed
This PR may require API review. If so, when the changes are ready, complete the pre-review checklist and request an API review. Status of requested reviews is tracked in the API Review project. |
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
/remove-kind api-change |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, mwielgus, vivekbagade 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 |
/retest |
1 similar comment
/retest |
@@ -1537,6 +1541,13 @@ func attachConfigMaps(template *v1.PodTemplateSpec, configMapNames []string) { | |||
template.Spec.Containers[0].VolumeMounts = mounts | |||
} | |||
|
|||
func (config *RCConfig) getTerminationGracePeriodSeconds(defaultGrace *int64) *int64 { |
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.
Why not just have the application logic at the use sites apply whatever logic they want? Do we have similar "get default value in certain situations" methods for all the other values?
In what situations does the default change? Why not use the same default throughout and make it a constant?
I'm not against having a method like this, but it seems slightly unnecessary and maybe even a bit confusing. If I was creating an object, I wouldn't know what the default should be and would expect that to just be set if there was a helper method like this. Otherwise this method is just a specific use case of
func firstPositiveInt64Val(vals ...*int64) *int64{
for _,v := range vals{
if v!=nil && *v>0 {return v}
}
}
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.
It seems this has maybe already been talked about by other comments and is otherwise lgtm/approved. Disregard if everyone is happy with it, but had just gotten around to review.
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Adding graceful termination to the test framework API
Special notes for your reviewer:
Does this PR introduce a user-facing change?: