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

Conversation

@vivekbagade
Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

commented Aug 30, 2019

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.

@@ -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),

This comment has been minimized.

Copy link
@neolit123

neolit123 Aug 30, 2019

Member

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.

This comment has been minimized.

Copy link
@MaciekPytel

MaciekPytel Aug 30, 2019

Contributor

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?

This comment has been minimized.

Copy link
@vivekbagade

vivekbagade Aug 30, 2019

Author Contributor

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

@vivekbagade vivekbagade force-pushed the vivekbagade:graceTermination branch from ff05857 to 4ae9a80 Aug 30, 2019
@vivekbagade vivekbagade force-pushed the vivekbagade:graceTermination branch from 4ae9a80 to dace541 Aug 30, 2019
@@ -569,7 +573,6 @@ func (config *RCConfig) create() error {
if config.DNSPolicy == nil {
config.DNSPolicy = &dnsDefault
}
one := int64(1)

This comment has been minimized.

Copy link
@mwielgus

mwielgus Aug 30, 2019

Contributor

Where is this default now?

This comment has been minimized.

Copy link
@vivekbagade

vivekbagade Aug 30, 2019

Author Contributor

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

This comment has been minimized.

Copy link
@mwielgus

mwielgus Aug 30, 2019

Contributor

What if someone sets it explicitly to 0?

This comment has been minimized.

Copy link
@vivekbagade

vivekbagade Aug 30, 2019

Author Contributor

Fixed

@fejta-bot

This comment has been minimized.

Copy link

commented Aug 30, 2019

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.

@vivekbagade vivekbagade force-pushed the vivekbagade:graceTermination branch from dace541 to c2b2e31 Aug 30, 2019
@vivekbagade vivekbagade force-pushed the vivekbagade:graceTermination branch from c2b2e31 to 6392b69 Aug 30, 2019
Copy link
Contributor

left a comment

/lgtm
/approve

@vivekbagade

This comment has been minimized.

Copy link
Contributor Author

commented Aug 30, 2019

/remove-kind api-change

@liggitt

This comment has been minimized.

Copy link
Member

commented Aug 30, 2019

/approve

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

commented Aug 30, 2019

[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

@vivekbagade

This comment has been minimized.

Copy link
Contributor Author

commented Aug 30, 2019

/retest

1 similar comment
@vivekbagade

This comment has been minimized.

Copy link
Contributor Author

commented Aug 30, 2019

/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 {

This comment has been minimized.

Copy link
@johnSchnake

johnSchnake Sep 1, 2019

Contributor

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

This comment has been minimized.

Copy link
@johnSchnake

johnSchnake Sep 1, 2019

Contributor

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
24 checks passed
24 checks passed
cla/linuxfoundation vivekbagade authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-conformance-image-test Skipped.
pull-kubernetes-conformance-kind-ipv6 Job succeeded.
Details
pull-kubernetes-cross Skipped.
pull-kubernetes-dependencies Job succeeded.
Details
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-100-performance Job succeeded.
Details
pull-kubernetes-e2e-gce-csi-serial Skipped.
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-e2e-gce-iscsi Skipped.
pull-kubernetes-e2e-gce-iscsi-serial Skipped.
pull-kubernetes-e2e-gce-storage-slow Skipped.
pull-kubernetes-godeps Skipped.
pull-kubernetes-integration Job succeeded.
Details
pull-kubernetes-kubemark-e2e-gce-big Job succeeded.
Details
pull-kubernetes-local-e2e Skipped.
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-node-e2e-containerd Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details
pull-publishing-bot-validate Skipped.
tide In merge pool.
Details
@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
You can’t perform that action at this time.