Skip to content

Conversation

@natasha41575
Copy link
Contributor

@natasha41575 natasha41575 commented Mar 4, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR has the kubelet set the condition's observedGeneration field as discussed in https://kep.k8s.io/5067.

Which issue(s) this PR fixes:

Pod generation KEP: https://kep.k8s.io/5067

Does this PR introduce a user-facing change?

The kubelet will set the `observedGeneration` field on pod conditions when the `PodObservedGenerationTracking` feature gate is set.

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

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

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/code-generation area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/kubelet do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. area/test needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 4, 2025
@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.

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 kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Mar 4, 2025
@k8s-ci-robot k8s-ci-robot requested review from aojea and apelisse March 4, 2025 20:45
@k8s-ci-robot k8s-ci-robot added sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Mar 4, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in SIG Apps Mar 4, 2025
@k8s-ci-robot k8s-ci-robot added the sig/storage Categorizes an issue or PR as relevant to SIG Storage. label Mar 4, 2025
@k8s-ci-robot k8s-ci-robot added the sig/testing Categorizes an issue or PR as relevant to SIG Testing. label Mar 4, 2025
@k8s-ci-robot k8s-ci-robot added the sig/windows Categorizes an issue or PR as relevant to SIG Windows. label Mar 4, 2025
@natasha41575
Copy link
Contributor Author

natasha41575 commented Mar 4, 2025

/priority important-soon

@natasha41575
Copy link
Contributor Author

/assign @liggitt

@natasha41575
Copy link
Contributor Author

/retest

Copy link
Member

@liggitt liggitt left a comment

Choose a reason for hiding this comment

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

the narrow change to the pkg/api helper looks fine... I left one comment about trying to improve the naming of that function in the future to avoid confusing people

once all the implementation changes are reviewed / approved, tag me for API package approval

// the API server preserving existing values when an incoming update tries to clear it.
func GetPodObservedGenerationIfEnabledOnCondition(pod *v1.Pod, conditionType v1.PodConditionType) int64 {
if pod == nil {
func GetPodObservedGenerationIfEnabledOnCondition(podStatus *v1.PodStatus, generation int64, conditionType v1.PodConditionType) int64 {
Copy link
Member

Choose a reason for hiding this comment

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

(preexisting / non-blocking)

rereading this, the function name / godoc on this function and the function above are confusing... it sounds like they will return observedGeneration, but they are returning generation

I'm having a hard time coming up with an alternative name that isn't ridiculously long, but I think the current names will lead to callers accidentally using these incorrectly

as a follow-up, consider if we can name these better to make it clearer the thing being returned is the passed-in generation or 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CalculatePodStatusObservedGeneration and CalculatePodConditionObservedGeneration maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’ll submit a follow up

Reason: v1.PodReasonTerminationByKubelet,
Message: message,
Type: v1.DisruptionTarget,
ObservedGeneration: podutil.GetPodObservedGenerationIfEnabledOnCondition(&pod.Status, pod.Generation, v1.DisruptionTarget),
Copy link
Member

Choose a reason for hiding this comment

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

This is going to get a little messy, but I don't think we can use pod.Status here. This condition gets passed to evictPod which in turn calls killPodFunc with a status-updating method. This should use the status that's passed in to that function.

Here's what I think you should do:

  1. Unconditionally set ObservedGeneration: pod.Generation here
  2. Before UpdatePodCondition is called (line 622), update the observed generation with GetPodObservedGenerationIfEnabledOnCondition:
		if condition != nil {
+			condition.ObservedGeneration = podutil.GetPodObservedGenerationIfEnabledOnCondition(status, condition.ObservedGeneration, condition.Type)
			podutil.UpdatePodCondition(status, condition)
		}

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, you could consider making this part of UpdatePodCondition, but that's a bigger change.

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, your comment made me think way harder about what is going on here (what I should have been doing to begin with)

fixed!

@natasha41575 natasha41575 force-pushed the pod-conditions branch 5 times, most recently from 1625ebf to fd59aed Compare March 18, 2025 15:42
@tallclair
Copy link
Member

/lgtm
/approve

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

LGTM label has been added.

Git tree hash: 4c07a7d235b8caf490c38e719cd811ec0b39b39c

@liggitt
Copy link
Member

liggitt commented Mar 19, 2025

/approve

for api helper function signature change

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 19, 2025
@k8s-ci-robot k8s-ci-robot merged commit 9f8a849 into kubernetes:master Mar 19, 2025
16 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.33 milestone Mar 19, 2025
@github-project-automation github-project-automation bot moved this from Archive-it to Done in SIG Node CI/Test Board Mar 19, 2025
@github-project-automation github-project-automation bot moved this from Needs Triage to Done in SIG Apps Mar 19, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hashim21223445, liggitt, natasha41575, tallclair

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

@natasha41575 natasha41575 deleted the pod-conditions branch October 13, 2025 17:53
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/code-generation area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/kubelet area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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 Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/testing Categorizes an issue or PR as relevant to SIG Testing. sig/windows Categorizes an issue or PR as relevant to SIG Windows. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Archived in project
Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants