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

add e2e test for restart kubelet #124445

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chengjoey
Copy link
Contributor

What type of PR is this?

e2e test for kubelet

/kind flake

What this PR does / why we need it:

when nodes removes the label that satisfies the pod affinity, the running pods are not affected, but restarting the kubelet will kill these pods.
#123980 As discussed in the related issue, there is no decision on whether to change the behavior of kubelet, but e2e tests can be added for tracking to facilitate subsequent verification of whether the changed code meets the expected behavior.

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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/flake Categorizes issue or PR as related to a flaky test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/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 Apr 22, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @chengjoey. 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 the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Apr 22, 2024
@k8s-ci-robot k8s-ci-robot added area/test sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 22, 2024
@kannon92
Copy link
Contributor

/ok-to-test

@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 Apr 22, 2024
@@ -260,3 +262,87 @@ var _ = SIGDescribe("Kubelet with pods in a privileged namespace", func() {
})
})
})

var _ = SIGDescribe("Kubelet rejects pods that do not satisfy affinity after restart", func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move the test here actually? https://github.com/kubernetes/kubernetes/blob/a63cc95cbec32e94054921877f08a75e215cc74d/test/e2e_node/restart_test.go

We have examples of restarting kubelet so I don't think you need changes to storage/utils.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thanks @kannon92

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 23, 2024
@chengjoey chengjoey force-pushed the e2e/kubelet-restart branch 3 times, most recently from fe740ab to 0128c2c Compare April 23, 2024 05:35
@kannon92
Copy link
Contributor

/test

@chengjoey
Copy link
Contributor Author

/test pull-kubernetes-node-kubelet-serial-crio-cgroupv2

/test pull-kubernetes-node-kubelet-serial-containerd

@chengjoey
Copy link
Contributor Author

/test pull-kubernetes-node-kubelet-serial-containerd

1 similar comment
@kannon92
Copy link
Contributor

/test pull-kubernetes-node-kubelet-serial-containerd

@kannon92
Copy link
Contributor

/test pull-kubernetes-node-kubelet-serial-containerd
/test pull-kubernetes-node-kubelet-serial-crio-cgroupv2

Fixed the eviction issues so this should look better now.

@kannon92
Copy link
Contributor

passed first run.
/test pull-kubernetes-node-kubelet-serial-containerd
/test pull-kubernetes-node-kubelet-serial-crio-cgroupv2

@kannon92
Copy link
Contributor

/test pull-kubernetes-node-kubelet-serial-containerd
/test pull-kubernetes-node-kubelet-serial-crio-cgroupv2

second run passed.

@kannon92
Copy link
Contributor

/cc @gjkim42

I see that you are also increasing coverage around restarts.

@gjkim42
Copy link
Member

gjkim42 commented Apr 29, 2024

/test pull-kubernetes-node-kubelet-serial-containerd

2 similar comments
@chengjoey
Copy link
Contributor Author

/test pull-kubernetes-node-kubelet-serial-containerd

@chengjoey
Copy link
Contributor Author

/test pull-kubernetes-node-kubelet-serial-containerd

Copy link
Member

@gjkim42 gjkim42 left a comment

Choose a reason for hiding this comment

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

It looks good to have an e2e test for this scenario.

/lgtm

/assign @SergeyKanzhelev
I think we can add this e2e test for now and fix it later if we want to fix the behavior. What do you think?

xref: #124586

gomega.Eventually(ctx, func() bool {
pod, err = e2epod.NewPodClient(f).Get(ctx, podName, metav1.GetOptions{})
framework.ExpectNoError(err)
// pod it is a final state
Copy link
Member

Choose a reason for hiding this comment

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

nit: pod is in a final state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -474,6 +474,73 @@ var _ = SIGDescribe("Restart", framework.WithSerial(), framework.WithSlow(), fra
return checkMirrorPodDisappear(ctx, f.ClientSet, pod.Name, pod.Namespace)
}, f.Timeouts.PodDelete, f.Timeouts.Poll).Should(gomega.BeNil())
})
// Regression test for an extended scenario for https://issues.k8s.io/123980
ginkgo.It("should kill running pods that were satisfied the affinity before kubelet restart", func(ctx context.Context) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: should evict running pods that do not meet the affinity after the kubelet restart

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 29, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: ae126d8e7a828e63cd0c9fe02c818fdc88e04a20

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 29, 2024
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot added the sig/auth Categorizes an issue or PR as relevant to SIG Auth. label Apr 29, 2024
when nodes removes the label that satisfies the pod affinity, the running pods are not affected, but restarting the kubelet will kill these pods.

Signed-off-by: joey <zchengjoey@gmail.com>
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: chengjoey
Once this PR has been reviewed and has the lgtm label, please ask for approval from sergeykanzhelev. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@Homura222
Copy link

Could you add another e2e test for pod.Spec.NodeSelector, please?

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Apr 29, 2024

@chengjoey: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-e2e-gce-providerless a63cc95 link false /test pull-kubernetes-e2e-gce-providerless
pull-kubernetes-node-kubelet-serial-containerd def47cc link false /test pull-kubernetes-node-kubelet-serial-containerd

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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.

@chengjoey
Copy link
Contributor Author

/test pull-kubernetes-unit

@chengjoey
Copy link
Contributor Author

Could you add another e2e test for pod.Spec.NodeSelector, please?

hi @Homura222 , the effects of using nodeAffinity and nodeSelector should be the same. In this e2e test, the purpose is just to schedule the pod to a specific node and restart the kubelet to test the evict logic. As for the node assignment function of the two itself, it should not belong to this test. This test is just to verify the characteristics of kubelet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/flake Categorizes issue or PR as related to a flaky test. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/node Categorizes an issue or PR as relevant to SIG Node. 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. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Status: Needs Triage
SIG Node CI/Test Board
PRs Waiting on Author
Status: Needs Reviewer
SIG Node PR Triage
Needs Reviewer
Development

Successfully merging this pull request may close these issues.

None yet

7 participants