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

Verify pod termination with E2E PreStop hook #94922

Merged
merged 1 commit into from Oct 1, 2020

Conversation

knabben
Copy link
Member

@knabben knabben commented Sep 20, 2020

What type of PR is this?
/kind cleanup
/kind flake
/sig node
/sig testing

What this PR does / why we need it:

This PR de-flaky the PreStop E2E node test by reducing the wait time period for checking the preStop hook test is being executed.

Which issue(s) this PR fixes:

Related #94918

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/flake Categorizes issue or PR as related to a flaky test. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/testing Categorizes an issue or PR as relevant to SIG Testing. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 20, 2020
@k8s-ci-robot
Copy link
Contributor

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

@knabben
Copy link
Member Author

knabben commented Sep 21, 2020

/assign @spiffxp

@@ -181,8 +179,8 @@ var _ = SIGDescribe("PreStop", func() {
testPreStop(f.ClientSet, f.Namespace.Name)
})

ginkgo.It("graceful pod terminated should wait until preStop hook completes the process [Flaky]", func() {
Copy link
Member

Choose a reason for hiding this comment

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

this PR effectively change what the test is validating. Original one was testing that if gracePeriod allows it and the pod preStop hook is configured to be long enough, pod will be running that preStop hook for the whole duration. New test checks that pod will not exist after grace period. Which doesn't confirm that preStop hook was executed. Is it correct understanding or a proposed change?

@@ -201,28 +199,8 @@ var _ = SIGDescribe("PreStop", func() {
err = podClient.Delete(context.TODO(), pod.Name, *metav1.NewDeleteOptions(gracefulTerminationPeriodSeconds))
framework.ExpectNoError(err, "failed to delete pod")

//wait up to graceful termination period seconds
time.Sleep(30 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

should the original test be fixed by changing this timeout to 15 second? 30 seconds is on the edge of graceful termination timeout and pod MAY or MAY NOT run at this ponit. After 15 seconds is is still running for sure if preStop hook is being executed.

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 21, 2020
@@ -202,7 +202,7 @@ var _ = SIGDescribe("PreStop", func() {
framework.ExpectNoError(err, "failed to delete pod")

//wait up to graceful termination period seconds
Copy link
Member

Choose a reason for hiding this comment

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

just a small suggestion - perhaps we can explain why it is 15 seconds in a comment here.

@SergeyKanzhelev
Copy link
Member

/ok-to-test
/lgtm
(will re-lgtm with the update of comment)

@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 Sep 21, 2020
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 21, 2020
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 21, 2020
@knabben
Copy link
Member Author

knabben commented Sep 23, 2020

Failed with another flaky - [sig-storage] HostPath should support r/w [NodeConformance]

@SergeyKanzhelev
Copy link
Member

/test pull-kubernetes-node-e2e

3 similar comments
@knabben
Copy link
Member Author

knabben commented Sep 23, 2020

/test pull-kubernetes-node-e2e

@spiffxp
Copy link
Member

spiffxp commented Sep 23, 2020

/test pull-kubernetes-node-e2e

@SergeyKanzhelev
Copy link
Member

/test pull-kubernetes-node-e2e

@knabben
Copy link
Member Author

knabben commented Sep 23, 2020

/test pull-kubernetes-node-e2e

@spiffxp good to go here?

@oomichi
Copy link
Member

oomichi commented Sep 25, 2020

This mark flake has been added since #83792 and the test was failed flaky at

framework.ExpectNoError(err, "validate-pod-is-running")

I am not sure what ratio of this test failure, can we know that at this time to make the test un-flake safely?
/test pull-kubernetes-node-e2e

@knabben
Copy link
Member Author

knabben commented Sep 25, 2020

@oomichi the test was sleeping for the entire graceful period (30 seconds), and checking if the pod is running in the extended grace period +2 seconds, reducing the sleep time in half will ensure the test is still running and is inside the grace period.

/test pull-kubernetes-node-e2e

time.Sleep(30 * time.Second)
// wait for less than the gracePeriod termination ensuring the
// preStop hook is still executing.
time.Sleep(15 * time.Second)

ginkgo.By("verifying the pod running state after graceful termination")
Copy link
Member

Choose a reason for hiding this comment

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

@oomichi the test was sleeping for the entire graceful period (30 seconds), and checking if the pod is running in the extended grace period +2 seconds, reducing the sleep time in half will ensure the test is still running and is inside the grace period.

Thanks for your explanation. I guess I got the point.
I'd like to summarize my understanding to know that is correct:

The original e2e test expects the pod is still Running after graceful termination (30 seconds in this test case) because of the extended 2 seconds as you said since

If one of the Pod's containers has defined a preStop hook, the kubelet runs that hook inside of the container.
If the preStop hook is still running after the grace period expires, the kubelet requests a small, one-off grace
period extension of 2 seconds.

of https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination

However that 2 seconds can make the test flake due to high workload at upstream CI systems sometimes.
Then this PR changes to verify the pod is still running before expiring the graceful termination during preStop hook is running.

If the above is correct, there are 2 points.

  • The above message needs to be updated because the graceful termination doesn't happen at the time.
  • Technically this test doesn't check preStop hook is running. the preStop outputs preStop to its stdout every 1 second but that is not checked on the test side. I don't think we need to add this check in this PR for the scope, it is better to add it with another PR.

Copy link
Member Author

@knabben knabben Sep 26, 2020

Choose a reason for hiding this comment

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

Yes, this is the rationality here.

  1. Maybe verifying the pod is running while in the graceful period termination
  2. Sure, the conformance test for the preHook follows this idea. I can propose another PR or even a new test with the stdout check logic.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, the above sounds good for me.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 28, 2020
@SergeyKanzhelev
Copy link
Member

/lgtm

thank you for updating the comment

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 28, 2020
@knabben
Copy link
Member Author

knabben commented Sep 28, 2020

/test pull-kubernetes-conformance-kind-ipv6-parallel

@oomichi
Copy link
Member

oomichi commented Sep 28, 2020

Thanks for updating.

/lgtm

@spiffxp
Copy link
Member

spiffxp commented Oct 1, 2020

I think I would prefer to merge the change in this PR, but remove the Flaky tag in a followup PR, based on data from https://testgrid.k8s.io/google-gce#gce-cos-master-flaky-repro

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 1, 2020
@knabben
Copy link
Member Author

knabben commented Oct 1, 2020

I agree, @spiffxp PTAL, I open another one to remove the flaky tag after we ensure it's been running flat.

@oomichi
Copy link
Member

oomichi commented Oct 1, 2020

Nice point to keep Flaky label to get data.

/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 1, 2020
Copy link
Member

@spiffxp spiffxp left a comment

Choose a reason for hiding this comment

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

/approve
Thank you! And thanks for your patience in getting this through

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: knabben, spiffxp

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 1, 2020
@knabben
Copy link
Member Author

knabben commented Oct 1, 2020

Flaky from:

go_test: //staging/src/k8s.io/legacy-cloud-providers/vsphere/go_default_test:run_2_of_2

/test pull-kubernetes-bazel-test

@k8s-ci-robot k8s-ci-robot merged commit 1ec3345 into kubernetes:master Oct 1, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Oct 1, 2020
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. kind/flake Categorizes issue or PR as related to a flaky test. 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. 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/node Categorizes an issue or PR as relevant to SIG Node. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants