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 the is the same standalone RayCluster as . - Install Kueue v0.16.5 with
Assistant
I'll start by exploring the repository structure and finding the relevant code related to this issue.
Assistant
Let me search for the relevant code.
Assistant
Now let me look at how
GetCustomAnnotationsis used in the RayCluster controller.Assistant
Let me look at the RayCluster controller itself to see how
GetCustomAnnotationsis implemented there.Assistant
Now let me look at the
jobframework/interface.gofor theGetCustomAnnotationsinterface definition and how it's used in the reconciler.Assistant
Let me look at the RayCluster webhook and check where
GetWorkloadNameExtraPartis used for RayCluster.Assistant
So the RayCluster controller does NOT implement
JobWithCustomAnnotationsorElasticWorkloadNameProviderdirectly. Let me check the webhook to understand how the annotations get written onto the standalone RayCluster. The issue says "RayCluster update webhook calls from the Kueue controller manager" - so it seems the webhook is being invoked when the RayCluster is patched.Let me look at the RayCluster webhook.
Assistant
The RayCluster controller does NOT implement
JobWithCustomAnnotationsorElasticWorkloadNameProviderdirectly. Let me check git history and understand how the standalone RayCluster writes the annotation back on itself.Assistant
Let me check the git branch and look at how the standalone RayCluster would implement
GetCustomAnnotations. The issue describes that for standalone RayClusters,GetCustomAnnotationscallsGetWorkloadslicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name).Assistant
This is the main branch (HEAD). The issue is about release-0.16, but let me check whether the same code path exists in main. Let me look at how the standalone RayCluster implements GetCustomAnnotations. The issue says it calls
GetWorkloadslicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name). But I don't see this in the raycluster_controller.go. Let me check git log for issue #10160.Actually, wait. Let me re-read. The main branch is checked out at HEAD 4cc62da8e. But the issue mentions release-0.16 branch. Let me check if the raycluster_controller.go in main implements these interfaces. It doesn't currently. So maybe the fix from #10160 wasn't merged to main, or maybe it's structured differently.
Wait, the issue says "This may be related to #10160, which added generation-based elastic workload names on the release-0.16 branch."
Let me look more carefully. The RayCluster controller currently does NOT implement JobWithCustomAnnotations or ElasticWorkloadNameProvider. But the issue describes that it does. So maybe the main branch is different from release-0.16.
Let me check if there's a release-0.16 branch.
Assistant
This is the commit referenced. Let me look at how the main branch raycluster controller handles the custom annotations. The issue says the standalone RayCluster implements
GetCustomAnnotations. Let me look at the git diff of this commit for rayjob and rayservice to understand the pattern, then check if raycluster also has GetCustomAnnotations.Assistant
Now I understand the structure. The issue says for standalone RayClusters,
GetCustomAnnotationscallsGetWorkloadslicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name). But the current main branch's raycluster_controller.go does NOT implementGetCustomAnnotations.Wait, the issue is reported on v0.16.5 (release-0.16 branch). But the repository here is on main branch. Let me check whether the raycluster controller on main actually implements these interfaces. The grep earlier showed it doesn't. So maybe the bug doesn't reproduce on main because the RayCluster controller doesn't implement GetCustomAnnotations on main?
Let me verify by checking the reconcile flow more carefully. The issue is about the standalone RayCluster. Let me look at the full current state and check if the RayCluster needs to implement GetCustomAnnotations for the replica sizes annotation to work.
Assistant
So on main, the RayCluster controller does NOT implement
GetCustomAnnotations. But the issue is reported against release-0.16 where it does.Wait, but the repository I'm given is the main branch. Let me check how the standalone RayCluster elastic job gets its replica sizes annotation written. Maybe on main, the standalone RayCluster uses a different path. Let me look at how the workload slicing path works for a standalone RayCluster.
Actually, let me re-read the issue. The issue is about a self-update loop. The fix suggested is: "A fix is to omit
kueue.x-k8s.io/raycluster-generationwhen thejobObjectis the same standalone RayCluster asrayClusterName."So the fix is in
GetWorkloadslicingRayClusterCustomAnnotations- whenjobObjectis the same as the RayCluster identified byrayClusterName, we should omit the generation annotation.But wait - on main, the RayCluster controller doesn't call
GetWorkloadslicingRayClusterCustomAnnotationsat all. Let me check whether the repository given is actually the release-0.16 branch or main.Let me check the version.
Assistant
So this is the main branch (
v0.0.0-main). The issue is reported against release-0.16. But the repository I'm given is the main branch.On main, the RayCluster controller does NOT implement
GetCustomAnnotations. So the self-update loop described in the issue doesn't reproduce on main in the same way. But the issue says the fix should be inGetWorkloadslicingRayClusterCustomAnnotationsto omit the generation annotation whenjobObjectis the same standalone RayCluster asrayClusterName.Wait, but if main doesn't even call
GetWorkloadslicingRayClusterCustomAnnotationsfor standalone RayClusters, then there's no bug on main. But the task is to fix the issue in this repository (main branch).Hmm, let me re-check. Maybe the RayCluster controller on main DOES implement these interfaces but I missed it. Let me search more broadly.
Assistant
So on main, the RayCluster controller does NOT implement
GetCustomAnnotationsorElasticWorkloadNameProvider. But the issue describes that standalone RayClusters DO self-update. This is on release-0.16.Let me look at the e2e test for standalone RayClusters to understand the expected behavior.
Assistant
The issue is about standalone RayClusters. Let me look at the standalone RayCluster e2e test specifically to understand the expected behavior
Assistant
Let me look at the e2e test for standalone RayClusters in the current main branch to understand the standalone RayCluster behavior.
Assistant
Let me look at the workload_names.go to understand how the standalone RayCluster builds workloadnames.
Assistant
Let me look at the reconciler to understand how
ElasticWorkloadNameProvideris used to build workload names for elastic jobs.Assistant
Now I understand the structure. Let me check the git history of the raycluster_controller.go to see if GetCustomAnnotations was ever added.
Assistant
Let me look at how the workload slicing path and annotations are used for standalone RayClusters. Let me examine the workloadslicing package.
Assistant
Let me check the git status and look at the standalone RayCluster e2e test in detail.
Assistant
OK, so the standalone RayCluster e2e test on main uses
GetWorkloadNameForRayClusterwhich doesn't include generation. The standalone RayCluster test is non-elastic (no elastic annotation).Let me now look at the elastic standalone RayCluster e2e test if it exists.
Assistant
Let me look at the raycluster controller test to understand the standalone RayCluster behavior expectations on main.
Assistant
Let me look at the
mergeAnnotationsfunction to understand when a patch is triggered.Assistant
Now let me understand how the replica sizes annotation is consumed in the workload slicing logic.
Assistant
So
ParsePodSetReplicaSizesandComparePodSetCountsare only used in common.go and tests. Let me check if they're used anywhere else.Assistant
Let me triple-check the raycluster package for any interface assertions or GetCustomAnnotations implementations.
Assistant
Confirmed. On main, the RayCluster only implements GenericJob and JobWithManagedBy. Let me understand how the standalone RayCluster's pod sets get autoscaled counts via
JobPodSets.Assistant
Let me look at the RayJob and RayService controllers to understand the full pattern of these interfaces.
Assistant
Let me check when RayJob/RayService got
GetCustomAnnotationsto understand if the RayCluster was supposed to get it too.Assistant
Let me look at the commit that added GetCustomAnnotations (dd27f9406 "Add podset-replica-sizes annotation on RayJob") to understand the original design. Let me see if the RayCluster was supposed to get it.
Assistant
Now I understand the full picture. The original design (#9726) added
GetCustomAnnotationsonly to RayJob, not RayCluster. On main, the standalone RayCluster does NOT implementGetCustomAnnotations, so the bug doesn't manifest on main the same way it does on release-0.16. However, the shared helperGetWorkloadslicingRayClusterCustomAnnotationscontains the latent bug: whenjobObjectis the same RayCluster asrayClusterName, it fetches that RayCluster and writes its own generation back, creating a self-update loop.The fix per the issue is to omit the
raycluster-generationannotation whenjobObjectis the same standalone RayCluster asrayClusterName. Let me apply this fix.Assistant
Now let me apply the fix:
Assistant
Now let me verify the build compiles and run the existing tests.
Assistant
Build succeeds. Now let me run the existing tests for the common.go file.
Assistant
All existing tests pass. Now let me write a temporary test to verify the standalone case is handled correctly (the generation annotation is omitted). I'll create a temporary test file, run it, then remove it.
Assistant
The fix works. The standalone RayCluster now omits the
raycluster-generationannotation while still returning the replica sizes annotation. Let me remove the temporary test file and run the broader test suite.Assistant
All tests pass. Let me review the final diff and run vet/format checks.
Assistant
gofmt and vet pass. Let me run the workloadslicing tests and a broader build to ensure nothing is broken.
Assistant
All tests pass. Let me run the RayJob
GetCustomAnnotationstest specifically to ensure the RayJob/RayService (non-standalone) path still works correctly.Assistant
All tests pass. Let me do a final check of the git status to ensure only the intended file is changed and there are no leftover temp files.
Assistant
Only the intended file is modified, and there are no leftover temp files. Let me do a final review of the complete fixed function.
Assistant
The fix is complete and correct. Let me run one final comprehensive test across all the relevant packages to confirm everything passes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.