Skip to content

add generation / observedGeneration test for mirror pods #132198

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

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

Conversation

natasha41575
Copy link
Contributor

What type of PR is this?

/kind cleanup
/area test

What this PR does / why we need it:

Add a test for generation and observedGeneration of mirror pods.

Which issue(s) this PR is related to:

Fixes #132162

Does this PR introduce a user-facing change?

NONE

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

- [KEP]: https://kep.k8s.io/5067

/sig node
/priority important-soon
/triage accepted

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. area/test sig/node Categorizes an issue or PR as relevant to SIG Node. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Jun 9, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. triage/accepted Indicates an issue or PR is ready to be actively worked on. labels Jun 9, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: natasha41575
Once this PR has been reviewed and has the lgtm label, please assign endocrimes for approval. For more information see the 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

@k8s-ci-robot k8s-ci-robot added the sig/testing Categorizes an issue or PR as relevant to SIG Testing. label Jun 9, 2025
for annotationKey, _ := range pod.Annotations {
if annotationKey == v1.MirrorPodAnnotationKey {
gomega.Expect(pod.Generation).To(gomega.BeEquivalentTo(1))
gomega.Expect(pod.Status.ObservedGeneration).To(gomega.BeEquivalentTo(0))
Copy link
Contributor Author

@natasha41575 natasha41575 Jun 9, 2025

Choose a reason for hiding this comment

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

I had been thinking about updating the podspec here to demonstrate / test that bumping the mirror podspecs result in generation getting bumped, something like this:

ginkgo.By("updating tolerations to trigger generation bump")
pod.Spec.Tolerations = append(pod.Spec.Tolerations, v1.Toleration{
	Key:      "pod-generation-test-" + string(uuid.NewUUID()),
	Operator: v1.TolerationOpEqual,
	Value:    "bar",
	Effect:   v1.TaintEffectNoSchedule,
})
_, err := f.ClientSet.CoreV1().Pods("kube-system").Update(ctx, &pod, metav1.UpdateOptions{})
framework.ExpectNoError(err, "failed to update pod")

updatedPod, err := f.ClientSet.CoreV1().Pods("kube-system").Get(ctx, pod.Name, metav1.GetOptions{})
framework.ExpectNoError(err, "failed to get pod")
gomega.Expect(updatedPod.Generation).To(gomega.BeEquivalentTo(currentGeneration + 1))
gomega.Expect(updatedPod.Status.ObservedGeneration).To(gomega.BeEquivalentTo(0))

but I felt that modifying the kube-system pods seems dangerous... not sure if there is a simple way to test the behavior of static pods here when their spec is modified (please let me know if there is). If not, then maybe best to leave it out.

Copy link
Member

Choose a reason for hiding this comment

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

Two ways:

  1. in test/e2e you can hack around and schedule a pod that will drop a new static pod into the manifests folder. This is not a great way forward.
  2. Use test/e2e_node and follow examples https://github.com/kubernetes/kubernetes/blob/master/test/e2e_node/mirror_pod_test.go and https://github.com/kubernetes/kubernetes/blob/master/test/e2e_node/standalone_test.go

Copy link
Member

Choose a reason for hiding this comment

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

@aojea is it a good thing to make tests rely on existence of at least one kube-system static pod? I remember somebody mentioned kube-proxy may go away?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the pointer! Will follow 2.

Copy link
Member

Choose a reason for hiding this comment

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

kube-proxy is only used as static pod in gke and gce scripts 🙃 , kubeadm uses a daemonset to deploy kube-proxy ... e2e test has to be agnostic of the cluster type so it does not seem a good idea to assume any cluster will have a kube-system static pod ...

@natasha41575
Copy link
Contributor Author

/assign @SergeyKanzhelev

@k8s-ci-robot
Copy link
Contributor

@natasha41575: 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-linter-hints dee0021 link false /test pull-kubernetes-linter-hints
pull-kubernetes-node-e2e-containerd dee0021 link true /test pull-kubernetes-node-e2e-containerd
pull-kubernetes-verify dee0021 link true /test pull-kubernetes-verify

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-sigs/prow repository. I understand the commands that are listed here.

@natasha41575 natasha41575 marked this pull request as draft June 10, 2025 03:13
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 10, 2025
@bart0sh bart0sh moved this from Triage to Work in progress in SIG Node: code and documentation PRs Jun 10, 2025
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. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. 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/S Denotes a PR that changes 10-29 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging this pull request may close these issues.

Add generation / observedGeneration tests for mirror pods
4 participants