Skip to content

Automated cherry pick of #15641: Use the Deployment UID for the job-uid label on Deployment Workloads - #16005

Merged
kubernetes-prow[bot] merged 2 commits into
kubernetes-sigs:release-0.18from
rjgoyln:cherry-pick-15641-to-release-0.18
Sep 22, 2026
Merged

kubernetes-prow[bot] merged 2 commits into
kubernetes-sigs:release-0.18from
rjgoyln:cherry-pick-15641-to-release-0.18

Conversation

@rjgoyln

@rjgoyln rjgoyln commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Cherry pick of #15641 on release-0.18.

#15641: Use the Deployment UID for the job-uid label on Deployment Workloads

For details on the cherry pick process, see the cherry pick requests page.

What type of PR is this?

/kind bug

Useful notes for your reviewer

  • DeploymentJobUIDLabel is Alpha and off by default here, not the Beta it is on main.
  • The ancestor walk and the integration registry are package-level on this branch, so the Pod integration carries no IntegrationManager.
Deployment: The Workload of a Deployment-managed Pod carries the Deployment UID in the `kueue.x-k8s.io/job-uid` label instead of the Pod UID. Gated by `DeploymentJobUIDLabel`, Alpha and disabled by default.

…ubernetes-sigs#15641)

* Use the Deployment UID for the job-uid label on Deployment Workloads

A Deployment produces one Workload per Pod, each labelled with its own Pod UID,
so nothing ties the Workloads of a single Deployment together. Topology spreading
therefore needs workloadLabelSelectors to group them.

Changing the label value is a semantic change for anyone already selecting
Workloads by job-uid, so it is gated behind DeploymentJobUIDLabel.

* Read the owning ReplicaSet as metadata and tolerate its absence

Fetching the typed ReplicaSet would start a cluster-wide informer caching every
ReplicaSet pod template just to read a UID; the owner traversal in jobframework
already reads unmanaged owners as metadata for that reason.

Treating a missing ReplicaSet as an error left an orphaned Pod gated forever with
the gate on, where the gate off produced a working Workload. A Pod that does not
resolve to a Deployment keeps its own UID instead.

* Cover the rolling update and gate-disabled paths

A Deployment keeps an outgoing and an incoming ReplicaSet alive at the same time,
and both sets of Pods have to land on the same job-uid for the label to be usable
as a grouping key.

The gate is meant to be inert when disabled, which is stronger than the resulting
label being unchanged: no ReplicaSet may be read at all.

* Explain why a missing ReplicaSet falls back instead of retrying

The branch reads as a swallowed error without the two facts that justify it: a
live Deployment's Pod always has its ReplicaSet, and the label is written once at
Workload creation and never re-synced, so retrying could not converge anyway.

* Soften the ReplicaSet-presence claim in the fallback comment

The comment asserted that the ReplicaSet is always there, one line above the
branch that handles it not being there.

* Scope the job-uid documentation to resolvable Deployments

Both the feature-gate comment and the label reference read as though enabling the
gate always yields the Deployment UID. A Pod that carries its own queue-name under
an unmanaged Deployment, or whose ReplicaSet is gone, keeps the Pod UID.

* Identify Deployment Pods by the parent that carried the queue-name

The suspended-by-parent annotation names the user-owned object the queue-name was
placed on, so that value is what decides whether the Deployment UID applies.
Matching on the annotation merely being present inferred the same thing from the
shape of the ownership chain, which is a weaker statement about the same fact.

The framework name moves to its own package because the pod integration cannot
import the deployment one: the latter's tests reach back into the pod package
through test/util, so a direct import is a cycle.

* Graduate DeploymentJobUIDLabel to Beta in 0.21

Sharing one job-uid across a parent's Workloads is what LeaderWorkerSet already
does, so the per-Pod value is the inconsistency rather than the new behaviour.

* Resolve the owning Deployment through the shared ancestor walk

FindAncestorJobManagedByKueue already traverses Pod -> ReplicaSet -> Deployment,
reads the interim ReplicaSet as metadata, and yields an ancestor only when Kueue
manages it and it carries the queue-name. That last condition is the property the
label is meant to name, so asserting the returned type beats inferring the same
thing from an annotation value, and the framework-name constant no longer needs a
package of its own.

The walk also surfaces a failed owner read instead of falling back. A cached
NotFound is not proof that the ReplicaSet is gone -- the Pod and ReplicaSet
informers advance independently -- and because the label is never re-synced, one
stale read would have pinned the Pod UID on that Workload for good.

* Cover the unqueued-ancestor paths and build fixtures from the wrappers

Threading manageJobsWithoutQueueName into the walk decides whether a Deployment
without a queue-name counts as the owner, and nothing exercised either answer.

The Deployment and StatefulSet fixtures now come from the testingjobs wrappers, as
the ancestor-walk test in jobframework already does, and the rolling update is two
more rows of the table rather than a second copy of the setup.

* Hold the feature gate at Alpha

Graduating it belongs with the release that ships integration coverage, not
with its introduction.

* Exercise the Deployment job-uid label against a live API server

The unit tests register a stand-in Deployment integration because the pod package
cannot import the real one, so nothing showed that the registration Kueue actually
ships resolves through the ancestor walk, or that the annotation the Deployment
webhook writes is the one the pre-filter reads.

The envtest suite runs no Deployment controller, so the ownership chain is built by
hand; that is also what keeps the test deterministic.

* Update pkg/controller/jobs/pod/pod_controller.go

Co-authored-by: Mykhailo Bobrovskyi <mikhail.bobrovsky@gmail.com>

* Restore the early return when the suspending parent is not a Deployment

The applied suggestion replaced the guard in place, which left it returning early
for exactly the Pods the label is meant for.

The value is compared rather than merely tested for presence because the annotation
is documented as free-form and users set it themselves for external controllers, so
its presence says nothing about a Deployment being the parent.

* Tighten the comment on the suspending-parent check

The two reasons a reader needs are why the value is compared and why it is a
literal; the rest was restating the code.

* Share the Deployment framework name with the pod integration

The pod integration matched the suspending parent against its own copy of the
string, so the value the Deployment webhook writes and the value read back could
drift apart. A constants package with no Kueue imports lets both sides name the
same constant, which a direct import cannot: the deployment package's tests reach
back into the pod package through test/util.

* Trim the constants package comment

The cycle is the reason the constant lives apart; which test import closes it is
not something a reader needs to carry.

* Cover the queue-name sitting on the Pod rather than the Deployment

A Pod can carry the queue-name itself under a Deployment Kueue does not manage,
and that Pod is managed standalone, so its Workload has to keep the Pod UID. The
previous case put the queue-name on neither object, which is a Pod Kueue would not
manage at all.

* Build the integration fixtures from the wrappers and drop a dead remap

The Deployment in the integration test was assembled by hand while the unit test
already used the wrapper, and the expected-UID remap never fired because every case
that wants the Pod UID uses a Pod whose UID is that literal.

* Shape the unmanaged-Deployment case the way production produces it

A Pod carrying the suspending-parent annotation under a Deployment without a
queue-name cannot occur: the webhook stamps that annotation only when it manages
the Deployment. The realistic shape is the Pod holding the queue-name itself with
nothing stamped on it at all.

The label reference now also says that enabling the gate leaves existing Workloads
alone, which the write-once behaviour otherwise hides.

* Update pkg/features/kube_features.go

Co-authored-by: Michał Woźniak <mimowo@users.noreply.github.com>

* Take feature gates as a map in the job-uid test and inline its assertion

A map lets a case set whatever gates it needs, which a single bool cannot, and the
gate now defaults to on, so every case states its own rather than relying on the
default.

Regenerates the feature-gate lists, which the in-place gate edit left behind.

---------

Co-authored-by: Mykhailo Bobrovskyi <mikhail.bobrovsky@gmail.com>
Co-authored-by: Michał Woźniak <mimowo@users.noreply.github.com>
@kubernetes-prow kubernetes-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Sep 22, 2026
@kubernetes-prow kubernetes-prow Bot added this to the v0.18 milestone Sep 22, 2026
@kubernetes-prow kubernetes-prow Bot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 22, 2026
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Excluded labels (none allowed) (3)
  • needs-ok-to-test
  • do-not-merge/work-in-progress
  • cncf-cla: no

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: kubernetes-sigs/kueue/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 3a34130f-f954-4f86-9ac2-1eb10f3111d8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit f332ea6
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-kueue/deploys/6ab28b18f4e817000823f401

@kubernetes-prow

Copy link
Copy Markdown

Hi @rjgoyln. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

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.

@kubernetes-prow kubernetes-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 22, 2026
@rjgoyln
rjgoyln marked this pull request as ready for review September 22, 2026 14:00
@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 22, 2026
This branch's PodWrapper derives an owner reference's UID from the name, so the
ReplicaSet in that case was never the one the Pod pointed at and the walk stopped
on the UID check, which the next case already covers.

The parent registration also carries its job type in the table rather than deriving
it again, and the integration setup drops the custom-labels wiring this branch's
own suite does not use.
@mimowo

mimowo commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

/ok-to-test

@kubernetes-prow kubernetes-prow Bot 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 22, 2026
@mimowo

mimowo commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 22, 2026
@kubernetes-prow

Copy link
Copy Markdown

LGTM label has been added.

DetailsGit tree hash: b30b5fe9f4820e622660fc8bbaaaf97cbbb2baef

@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mimowo, rjgoyln

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

The pull request process is described 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

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 22, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit acbf5d2 into kubernetes-sigs:release-0.18 Sep 22, 2026
58 checks passed
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants