Skip to content

Conversation

@herb-duan
Copy link

What type of PR is this?

/kind cleanup
/kind test

What this PR does / why we need it:

This PR introduces a new test TestIsPodStatusByKubeletEqualFutureProof to make the pod status equality logic more robust and prevent future regressions.

Key improvements:

  1. Future-proof validation: Uses reflection to ensure all v1.PodStatus fields are explicitly categorized as kubelet-owned or ignored (fails fast if new fields are added).
  2. Comprehensive coverage: Verifies both ignored fields (ResourceClaimStatuses/ExtendedResourceClaimStatus) and owned fields (Phase/PodIPs) are handled correctly.
  3. Transparent TODO: Documents NominatedNodeName (marked as ignored but not handled by current logic) for further discussion.

This addresses reviewer feedback from #136238 to avoid reintroduction of unnecessary kubelet reconciliation loops for new non-kubelet-owned PodStatus fields.

Which issue(s) this PR is related to:

Follow-up to #136238
Indirectly relates to #136239

Special notes for your reviewer:

  • The test enforces explicit categorization of all PodStatus fields (prevents untested new fields from causing regressions).
  • NominatedNodeName is marked as ignored but not handled by isPodStatusByKubeletEqual (TODO: discuss whether to update the equality logic).

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jan 26, 2026
@k8s-ci-robot
Copy link
Contributor

@herb-duan: The label(s) kind/test cannot be applied, because the repository doesn't have them.

Details

In response to this:

What type of PR is this?

/kind cleanup
/kind test

What this PR does / why we need it:

This PR introduces a new test TestIsPodStatusByKubeletEqualFutureProof to make the pod status equality logic more robust and prevent future regressions.

Key improvements:

  1. Future-proof validation: Uses reflection to ensure all v1.PodStatus fields are explicitly categorized as kubelet-owned or ignored (fails fast if new fields are added).
  2. Comprehensive coverage: Verifies both ignored fields (ResourceClaimStatuses/ExtendedResourceClaimStatus) and owned fields (Phase/PodIPs) are handled correctly.
  3. Transparent TODO: Documents NominatedNodeName (marked as ignored but not handled by current logic) for further discussion.

This addresses reviewer feedback from #136238 to avoid reintroduction of unnecessary kubelet reconciliation loops for new non-kubelet-owned PodStatus fields.

Which issue(s) this PR is related to:

Follow-up to #136238
Indirectly relates to #136239

Special notes for your reviewer:

  • The test enforces explicit categorization of all PodStatus fields (prevents untested new fields from causing regressions).
  • NominatedNodeName is marked as ignored but not handled by isPodStatusByKubeletEqual (TODO: discuss whether to update the equality logic).

Does this PR introduce a user-facing change?

NONE

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.

@k8s-ci-robot k8s-ci-robot added 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. labels Jan 26, 2026
@k8s-ci-robot
Copy link
Contributor

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.

Details

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.

@k8s-ci-robot
Copy link
Contributor

Hi @herb-duan. 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.

Details

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.

@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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 26, 2026
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jan 26, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: herb-duan
Once this PR has been reviewed and has the lgtm label, please assign klueska for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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

This commit introduces a new test, TestIsPodStatusByKubeletEqualFutureProof, to make the verification of the pod status equality logic more robust and prevent future regressions.

The previous test was brittle as it only checked a few specific fields. It would not have detected issues if new fields were added to the v1.PodStatus struct, potentially re-introducing bugs where the kubelet performs unnecessary status updates.

Following reviewer feedback, the new test uses reflection to ensure every field in v1.PodStatus is explicitly categorized as either kubelet-owned or ignored. The test will now fail if it encounters an unknown field, forcing any developer who modifies v1.PodStatus to consciously update the equality logic and its corresponding tests.

The test includes sub-tests to verify that:
- Changes to ignored fields (e.g., ResourceClaimStatuses) are correctly ignored.
- Changes to owned fields (e.g., Phase, PodIPs) are correctly detected.

ResourceClaimStatuses/ExtendedResourceClaimStatus test cases are temporarily commented out (depend on PR kubernetes#136238 merge). A TODO has been added for NominatedNodeName, as it is identified as a field that should be ignored, but the current equality function does not handle it. This is left for further discussion.

Signed-off-by: Herb Duan <herbertduan@qq.com>
@herb-duan herb-duan force-pushed the test-kubelet-podstatus-future-proof branch from 3b7535c to ac8f02c Compare January 26, 2026 17:53
@herb-duan herb-duan changed the title test(kubelet): add future-proof test for PodStatus equality [WIP] test(kubelet): add future-proof test for PodStatus equality Jan 26, 2026
@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 Jan 26, 2026
@herb-duan
Copy link
Author

Hi @pohly,

This is the follow-up PR for the future-proof test we discussed in #136238.

NOTE: This PR is WIP and depends on PR #136238 being merged first.

Key notes for this PR:

  1. The test uses reflection to enforce explicit categorization of all v1.PodStatus fields (kubelet-owned/ignored) — fails fast if new fields are added, preventing regressions.
  2. ResourceClaimStatuses/ExtendedResourceClaimStatus test cases are temporarily commented out (will uncomment after fix(kubelet): ignore resource claim statuses in pod status comparison #136238 is merged).
  3. NominatedNodeName is marked as ignored in the test but not handled by current isPodStatusByKubeletEqual logic (TODO for discussion).

Could you please review this PR when you have time? Also, could you help with /ok-to-test to trigger the CI tests?

Thanks!

/sig node
/triage accepted
/priority important-soon
/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jan 26, 2026
@k8s-ci-robot
Copy link
Contributor

@herb-duan: The label triage/accepted cannot be applied. Only GitHub organization members can add the label.

Details

In response to this:

Hi @pohly,

This is the follow-up PR for the future-proof test we discussed in #136238.

NOTE: This PR is WIP and depends on PR #136238 being merged first.

Key notes for this PR:

  1. The test uses reflection to enforce explicit categorization of all v1.PodStatus fields (kubelet-owned/ignored) — fails fast if new fields are added, preventing regressions.
  2. ResourceClaimStatuses/ExtendedResourceClaimStatus test cases are temporarily commented out (will uncomment after fix(kubelet): ignore resource claim statuses in pod status comparison #136238 is merged).
  3. NominatedNodeName is marked as ignored in the test but not handled by current isPodStatusByKubeletEqual logic (TODO for discussion).

Could you please review this PR when you have time? Also, could you help with /ok-to-test to trigger the CI tests?

Thanks!

/sig node
/triage accepted
/priority important-soon
/release-note-none

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.

@k8s-ci-robot k8s-ci-robot removed the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Jan 26, 2026
t.Fatalf("New fields found in v1.PodStatus: %v. Please add them to either "+
"kubeletOwnedFields or kubeletIgnoredFields in TestIsPodStatusByKubeletEqualFutureProof "+
"and update isPodStatusByKubeletEqual logic if necessary.", unknownFields.List())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a good start for the test.

}

// Verify that changes to fields that are not owned by kubelet are ignored.
t.Run("ignored fields are ignored", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The two sub-tests rely on manually writing test data. If someone adds a new field to the lists above and then forgets to extend the sub-tests, nothing fails and in a diff it's not obvious that something is missing, so it might also not get caught in review.

My idea was to generate different statuses with https://github.com/kubernetes-sigs/randfill, then determine based on the lists above whether a status should be considered equal or different.

Fuzzing is not guaranteed to hit all fields, although in practice it probably will very quickly. If we want to be more systematic, we can also manually set one field at a time. That's better because then we are sure that this one field is correctly handled by isPodStatusByKubeletEqual.

Fuzzing is not generating valid statuses, but this might be good enough for isPodStatusByKubeletEqual?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/kubelet 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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Development

Successfully merging this pull request may close these issues.

3 participants