ISSUE DESCRIPTION Standalone elastic RayCluster self-updates raycluster-generation…
- User
ISSUE DESCRIPTION
Standalone elastic RayCluster self-updates raycluster-generation annotation What happened:
A standalone Kueue-managed elastic RayCluster is continuously updated by Kueue.
The
kueue.x-k8s.io/raycluster-generationannotation tracks the RayCluster's ownmetadata.generation, but remains one value behind. For example:metadata.generation: 273390 kueue.x-k8s.io/raycluster-generation: "273389"A later read showed the same pattern:
metadata.generation: 273462 kueue.x-k8s.io/raycluster-generation: "273461"Kueue logs showed repeated RayCluster reconciles followed by RayCluster update webhook calls from the Kueue controller manager.
This is a self-triggered loop in the RayCluster custom annotation path. For standalone RayClusters,
GetCustomAnnotationscallsGetWorkloadslicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name). That helper fetches the same RayCluster and returns the fetched RayCluster generation as an annotation to write back onto the RayCluster. The metadata patch then advances the RayCluster generation, making the annotation stale again.What you expected to happen:
Kueue should not continuously patch a standalone elastic RayCluster when its replica counts have not changed.
The
raycluster-generationannotation is useful for RayJob and RayService, where the top-level object needs to account for an underlying RayCluster generation. A standalone RayCluster should not write its own generation back onto itself.How to reproduce it (as minimally and precisely as possible):
- Install Kueue v0.16.5 with
ElasticJobsViaWorkloadSlices=true. - Enable the RayCluster integration.
- Create a standalone RayCluster with:
metadata: annotations: kueue.x-k8s.io/elastic-job: "true" labels: kueue.x-k8s.io/queue-name: <local-queue>- Inspect the RayCluster generation and annotation repeatedly:
kubectl get raycluster.ray.io <name> -n <namespace> \ -o jsonpath='{.metadata.generation}{"\t"}{.metadata.annotations.kueue\.x-k8s\.io/raycluster-generation}{"\n"}'Anything else we need to know?:
This may be related to #10160, which added generation-based elastic workload names on the release-0.16 branch.
A fix is to omit
kueue.x-k8s.io/raycluster-generationwhen thejobObjectis the same standalone RayCluster asrayClusterName.Environment:
- Kubernetes version (use
kubectl version):- Client Version: v1.33.9
- Server Version: v1.33.10-gke.1115000
- Kueue version (use
git describe --tags --dirty --always):- Deployed controller image:
kueue:v0.16.5 - Helm chart:
kueue-0.16.5
- Deployed controller image:
- Cloud provider or hardware configuration: GKE
- OS (e.g:
cat /etc/os-release): not collected - Kernel (e.g.
uname -a): not collected - Install tools: Helm
- Others:
ElasticJobsViaWorkloadSlices=trueTopologyAwareScheduling=false
Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /kueue, current file: none) bash-$
- Install Kueue v0.16.5 with
Assistant
Now let me apply the fix.
Assistant
The fix is complete. Let me verify final state once more and go over the checklist.
Assistant
Checklist review:
-
"If an error was reported in the issue description, I have successfully reproduced it." The issue reports a self-triggered patch loop of the
kueue.x-k8s.io/raycluster-generationannotation on a standalone elastic RayCluster (needs a live cluster with the ElasticJobsViaWorkloadSlices gate, so it cannot be reproduced literally here). I reproduced the root cause at unit level:GetWorkloadslicingRayClusterCustomAnnotationsreturnedRayClusterGenerationAnnotationcontaining the fetched RayCluster's own generation even when the passedjobObjectis that same RayCluster (verified with a temporary test where the job object was a RayCluster namedtest-rayclusterwith generation 7 — the helper returnedraycluster-generation: "7"to be written back onto itself, i.e. the stale-by-one loop described in the issue). -
"If an error was reported in the issue description, I have confirmed that my fix resolves the error." After the fix, that temporary test showed the helper returns only
kueue.x-k8s.io/raycluster-podset-replica-sizesand omitskueue.x-k8s.io/raycluster-generationfor a self-referencing (standalone) RayCluster, so nothing is patched back onto the RayCluster when replica counts are unchanged, breaking the loop. The temporary test file was removed afterwards. -
"I have thought about edge cases and made sure my fix handles them as well."
- Workload slicing disabled → still returns
nil(unchanged). - RayJob/RayService (top-level object with a differently named owned RayCluster) → generation annotation still produced (behavior preserved).
- RayCluster not found → still returns empty generation value instead of failing.
- Non-NotFound Get errors → still surfaced as errors.
- Empty
rayClusterName(e.g. RayJob/RayService before the cluster exists) → not treated as self-reference, keeps previous behavior (empty generation via NotFound path). - The API
Getis skipped entirely in the standalone case, avoiding a needless read. - Serialization error handling preserved (it is now checked first, which cannot regress since it never depends on the Get).
- Workload slicing disabled → still returns
-
"I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass."
go test ./pkg/controller/...passes (includingpkg/controller/jobs/raycluster,rayjob,rayservice, andjobframework), plusgo build ./pkg/...,gofmt, andgo vetare clean. No existing tests were modified or added. Integration/e2e tests do not reference the generation annotation.
I'm confident in the change; submitting.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →