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

Cleanup non-namespaced objects in e2e test during interrupts #96023

Merged

Conversation

chrishenzie
Copy link
Member

@chrishenzie chrishenzie commented Oct 29, 2020

/sig storage

What type of PR is this?
/kind bug

What this PR does / why we need it:
This PR fixes an issue where if this e2e test is interrupted, only the namespace gets cleaned up. Non-namespaced objects like StorageClasses are not cleaned up.

Which issue(s) this PR fixes:

Fixes #96022

Special notes for your reviewer:

The test framework has an AddAfterEach() block that allows us to handle this test cleanup logic.

Since we are handling the test cleanup in an AfterEach() step, I figured it was intuitive to handle the equivalent test setup in a BeforeEach() step. I split this into two parts. One that asserts things before the test framework is created (which creates a namespace), and one that sets up everything else after. These BeforeEach() blocks run sequentially before every It() block.

Does this PR introduce a user-facing change?:

NONE

@msau42

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. sig/storage Categorizes an issue or PR as relevant to SIG Storage. kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 29, 2020
@k8s-ci-robot
Copy link
Contributor

@chrishenzie: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 29, 2020
@k8s-ci-robot
Copy link
Contributor

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

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Oct 29, 2020
@msau42
Copy link
Member

msau42 commented Oct 29, 2020

/ok-to-test
/assign @gnufied
I thought we already did this?

Edit: nm I spoke too soon, this is adding it just to the testsuite

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 29, 2020

l.pods = append(l.pods, pod)
}
f.AddAfterEach("cleanup", func(f *framework.Framework, failed bool) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you know what the difference is between AddAfterEach and ginkgo.AfterEach?

Copy link
Member Author

Choose a reason for hiding this comment

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

AddAfterEach appends a function to execute as part of the framework's AfterEach, which is registered with ginkgo via ginkgo.AfterEach:

ginkgo.AfterEach(f.AfterEach)

I expected I could replace this with a call to ginkgo.AfterEach and see it work, but when I tested it, it didn't run.

Copy link
Member

Choose a reason for hiding this comment

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

That's unexpected. Most of our other tests do not use AddAfterEach. It may be worth following up with sig-testing on this.

@msau42
Copy link
Member

msau42 commented Oct 30, 2020

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrishenzie, msau42

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 Oct 30, 2020
@msau42
Copy link
Member

msau42 commented Oct 30, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 30, 2020
@k8s-ci-robot k8s-ci-robot merged commit 3d62aad into kubernetes:master Oct 30, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Oct 30, 2020
@chrishenzie chrishenzie deleted the e2e-cleanup-non-namespaced-objects branch October 30, 2020 18:15
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/bug Categorizes issue or PR as related to a bug. 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. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/storage Categorizes an issue or PR as relevant to SIG Storage. 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.

Cleanup non-namespaced objects in interrupted e2e tests
4 participants