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

kubectl/drain: add disable-eviction option #85571

Merged

Conversation

@michaelgugino
Copy link
Contributor

michaelgugino commented Nov 23, 2019

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test

/kind feature

/kind flake

What this PR does / why we need it:
Currently, if eviction is supported during a drain operation,
eviction is always used.

This commit allows the user to specify disabling eviction.
This is particularly useful when you wish to ignore
PodDisruptionBudgets after a normal drain has failed for
some time.

Which issue(s) this PR fixes:

Fixes #83307

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

kubectl/drain: add disable-eviction option.
Force drain to use delete, even if eviction is supported. This will bypass checking PodDisruptionBudgets, and should be used with caution.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Nov 23, 2019

Hi @michaelgugino. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@mortent

This comment has been minimized.

Copy link
Member

mortent commented Dec 2, 2019

/ok-to-test

Copy link
Member

mortent left a comment

I think this looks good. Just a small comment.

for _, evictionSupported := range []bool{true, false} {
evictionSupported := evictionSupported
t.Run(fmt.Sprintf("evictionSupported=%v", evictionSupported),
tests := []struct {

This comment has been minimized.

Copy link
@mortent

mortent Dec 2, 2019

Member

Would it be better to turn this into map[string]struct{} so we can name each of the test cases? I think that could be useful to provide more context on what is being tested in each example. We can then use the name in the t.Run call on line 245.

This comment has been minimized.

Copy link
@michaelgugino

michaelgugino Dec 2, 2019

Author Contributor

That's not really a pattern I've seen elsewhere. We could do something like this:

Honestly, I don't think it's really necessary in this case, there's not really much to describe and there are only 4 tests.

This comment has been minimized.

Copy link
@mortent

mortent Dec 3, 2019

Member

Both patterns are used in the code base, I'm ok with either one. I just would like the name of the test used in t.Run to uniquely identify each case. It makes it much easier to understand what is going on if tests fail, in particular when it runs on Prow. Also, with a unique name we don't need to print the number of the test case in the t.Errorf statements.

This comment has been minimized.

Copy link
@michaelgugino

michaelgugino Dec 3, 2019

Author Contributor

@mortent @seans3 I went ahead and added the 'description' to be consistent in the package.

@seans3

This comment has been minimized.

Copy link
Contributor

seans3 commented Dec 2, 2019

/priority important-longterm

@seans3
seans3 approved these changes Dec 3, 2019
Copy link
Contributor

seans3 left a comment

This looks good. Again, I appreciate the sharp focus, and the unit tests. I would add more comments, but that is up to you.

@@ -51,6 +51,7 @@ type Helper struct {
DeleteLocalData bool
Selector string
PodSelector string
DisableEviction bool

This comment has been minimized.

Copy link
@seans3

seans3 Dec 3, 2019

Contributor

I would add a significant comment here that fully describes disabling eviction.

@seans3

This comment has been minimized.

Copy link
Contributor

seans3 commented Dec 3, 2019

/lgtm
/approve

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Dec 3, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: michaelgugino, seans3

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

@seans3

This comment has been minimized.

Copy link
Contributor

seans3 commented Dec 3, 2019

/hold

Holding until resolution on mortent's comments

Currently, if eviction is supported during a drain operation,
eviction is always used.

This commit allows the user to specify disabling eviction.
This is particularly useful when you wish to ignore
PodDisruptionBudgets after a normal drain has failed for
some time.
@michaelgugino michaelgugino force-pushed the mgugino-upstream-stage:drain-ignore-pdbs branch from 366b834 to 6c1d587 Dec 3, 2019
@k8s-ci-robot k8s-ci-robot added size/L and removed lgtm size/M labels Dec 3, 2019
@mortent
mortent approved these changes Dec 3, 2019
Copy link
Member

mortent left a comment

/lgtm

}
expected := []string{"default/mypod-3", "default/mypod-4"}
if !reflect.DeepEqual(remainingPods, expected) {
t.Errorf("%s: unexpected remaining pods after DeleteOrEvictPods; actual %v; expected %v", tc.description, remainingPods, expected)

This comment has been minimized.

Copy link
@mortent

mortent Dec 3, 2019

Member

Nit. The description shouldn't be needed here. Since each example is a separate subtest the framework will include this information for test failures.

This comment has been minimized.

Copy link
@michaelgugino

michaelgugino Dec 3, 2019

Author Contributor

I felt it was a little redundant, I was just following the existing pattern. Perhaps I'll cleanup the package in a follow up.

@seans3

This comment has been minimized.

Copy link
Contributor

seans3 commented Dec 4, 2019

/assign @cheftako

@seans3

This comment has been minimized.

Copy link
Contributor

seans3 commented Dec 4, 2019

/hold cancel

@k8s-ci-robot k8s-ci-robot merged commit b42f219 into kubernetes:master Dec 4, 2019
14 of 15 checks passed
14 of 15 checks passed
tide Not mergeable. Retesting: pull-kubernetes-kubemark-e2e-gce-big
Details
cla/linuxfoundation michaelgugino authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
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-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-e2e-kind Job succeeded.
Details
pull-kubernetes-integration Job succeeded.
Details
pull-kubernetes-kubemark-e2e-gce-big Job succeeded.
Details
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
@k8s-ci-robot k8s-ci-robot added this to the v1.18 milestone Dec 4, 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.