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

Adding termination grace period to Deployment, RC, RCSet, and Job #82170

Merged
merged 1 commit into from
Sep 11, 2019
Merged

Adding termination grace period to Deployment, RC, RCSet, and Job #82170

merged 1 commit into from
Sep 11, 2019

Conversation

vivekbagade
Copy link
Contributor

@vivekbagade vivekbagade commented Aug 30, 2019

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?:

Adding TerminationGracePeriodSeconds to the test framework API

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 30, 2019
@k8s-ci-robot
Copy link
Contributor

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.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 30, 2019
@@ -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),
Copy link
Member

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 30, 2019
@@ -569,7 +573,6 @@ func (config *RCConfig) create() error {
if config.DNSPolicy == nil {
config.DNSPolicy = &dnsDefault
}
one := int64(1)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@@ -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))
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@fejta-bot
Copy link

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.

@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Aug 30, 2019
Copy link
Contributor

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

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 30, 2019
@vivekbagade
Copy link
Contributor Author

/remove-kind api-change

@k8s-ci-robot k8s-ci-robot removed the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Aug 30, 2019
@liggitt
Copy link
Member

liggitt commented Aug 30, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[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 /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 Aug 30, 2019
@vivekbagade
Copy link
Contributor Author

/retest

1 similar comment
@vivekbagade
Copy link
Contributor Author

/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 {
Copy link
Contributor

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

Copy link
Contributor

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.

@k8s-ci-robot k8s-ci-robot merged commit e3b5062 into kubernetes:master Sep 11, 2019
@k8s-ci-robot k8s-ci-robot added this to the v1.17 milestone Sep 11, 2019
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. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants