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:consolemetadata.generation: 273390 kueue.x-k8s.io/raycluster-generation: "273389"A later read showed the same pattern:
consolemetadata.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:
yamlmetadata: annotations: kueue.x-k8s.io/elastic-job: "true" labels: kueue.x-k8s.io/queue-name: <local-queue>- Inspect the RayCluster generation and annotation repeatedly:
sh - Install Kueue v0.16.5 with
Assistant
Let me start by understanding the repository structure and the issue described.
The issue is about a standalone elastic RayCluster that self-updates the
raycluster-generationannotation. The problem is thatGetCustomAnnotationscallsGetWorkloadslicingRayClusterCustomAnnotations, which fetches the RayCluster and returns its generation as an annotation to write back onto the same RayCluster. This creates a self-triggered loop.The fix should omit
kueue.x-k8s.io/raycluster-generationwhen thejobObjectis the same standalone RayCluster.Let me explore the codebase to understand the relevant code.
Assistant
Let me look at the relevant files. The key file seems to be
raycluster/common.go.Assistant
Now let me understand how
GetWorkloadslicingRayClusterCustomAnnotationsis called and the flow for standalone RayClusters:Assistant
Now let me check the reconciler to see how
GetCustomAnnotationsis called for standalone RayClustersAssistant
Let me look at the reconciler context around line 961
Assistant
The open command needs to be called using the bash terminal. Let me use
catto view the file contents.Assistant
Let me find the standalone RayCluster controller to see how
GetCustomAnnotationsis defined for it.Assistant
Let me check the interface definition and the RayCluster controller for whether it implements
JobWithCustomAnnotations.Assistant
Let me look at the interface definition and the RayCluster controller.
Assistant
Let me find the RayCluster controller file and check what it implements
Assistant
Let me search for any
GetCustomAnnotationsimplementation in the racluster directory more thoroughly.Assistant
Let me check if RayCluster implements
ElasticWorkloadNameProviderand howGetWorkloadNameExtraPartis usedAssistant
Let me look at the reconciler around the workload name usage
Assistant
Let me look at
workloadslicing.EnsureWorkloadSlicesand how annotations are written in the workload slicing pathAssistant
Let me look at
EnsureWorkloadSlicesimplementationAssistant
Let me look at the workloadslicing package.
Assistant
Let me look at the reconciler more carefully to see how the annotations and path flow for standalone RayCl
Assistant
Let me search for all implementations of
GetCustomAnnotationsin the codeAssistant
Let me look at the full reconciler flow for workload
Assistant
Let me check git log for recent changes to the racluster files
Assistant
Let me look at the diff from the generation-based elastic workload names
Assistant
Let me look at the diff from this commit for reconciler.go and the racluster changes
Assistant
Let me look at the full diff for racluster common.go from the
Assistant
Let me search for any place where
GetWorkloadslicingRayClusterCustomAnnotationsmight be called for a standalone RayClusterAssistant
Let me look at the reconciler test to understand the issue
Assistant
Let me look at where ConstructWorkload is
Assistant
Let me look at the context around line 1301 and 166
Assistant
Let me look at the context around line 166
Assistant
Let me look at the mergeAnnotations
Assistant
Let me look at the mergeAnnotations function
Assistant
Let me look at the racluster webhook
Assistant
Let me search for how the reconciler handles the case when workloadslicing is enabled and the workload slices are compatible
Assistant
Let me look at the tests for `GetWorkloadslicingRayClusterCustom
Assistant
Let me look at how the reconciler handles
nil, nilfrom ensureOneWorkloadAssistant
Let me look at the reconciler around line 397
Assistant
Let me look further at what happens when wl is
Assistant
Let me look at handleJobWithNoWorkload
Assistant
Let me see handleJobWithNoWork
Assistant
Let me double-check if RayCluster implements
JobWithCustomAnnotationsorElasticWorkloadNameProviderAssistant
Let me search for all places that set annotations on the Ray
Assistant
Let me check the WorkloadSliceEnabled
Assistant
Let me look at the WorkloadSliceEnabled
<|DSML|tool_calls> <|DSML|invoke name="bash_terminal"> <|DSML|parameter name="command" string="true">sed -n '1809,1825p' /kueue/pkg/controller/jobframework/reconciler.go</|DSML|parameter> </|DSML|invoke> </|DSML|tool_calls>
Assistant
Let me check all commits for the racluster controller file
Assistant
Let me look at ensurePrebuiltWorkloadInSync
Assistant
Let me find when updateWorkloadToMatchJob is called
Assistant
Let me look at the context around line 106
Assistant
Let me look at the e2e tests to understand the expected behavior
Assistant
Let me find any e2e tests for kuberay
Assistant
Let me look at the racluster controller integration test for clues
Assistant
Let me look at the elastic job integration test
Assistant
Let me look at UpdatePodSets more carefully
Assistant
Let me look at the full elastic tests in the raycluster integration test
Assistant
Now I understand the issue. Let me verify my understanding and implement the fix.
The issue is in
GetWorkloadslicingRayClusterCustomAnnotations. When thejobObjectis the same as therayClusterName(i.e., it's a standalone RayCluster), fetching its own generation and writing it back as an annotation creates an infinite loop: each patch increments the generation, making the annotation stale, triggering another patch.The fix: skip adding
RayClusterGenerationAnnotationwhenjobObject.GetName() == rayClusterName.Let me first write a simple test script to confirm the logic, then apply the fix.
Assistant
Let me set up the environment.
Assistant
Let me find the exact test function name.
Assistant
Let me run the existing test.
Assistant
Now let me implement the fix. The change should be in
GetWorkloadslicingRayClusterCustomAnnotationsincommon.go. When thejobObjecthas the same name asrayClusterName(and same namespace), we should not include theRayClusterGenerationAnnotationto avoid the self-referencing loopAssistant
Let me view the function to understand exactly what needs to change.
Assistant
Now I'll implement the fix. The fix should skip adding
RayClusterGenerationAnnotationwhen thejobObjectis the same asrayClusterName(i.e., they refer to the same objectAssistant
Let me use sed to make the change
Assistant
Let me verify the change
Assistant
Now let me run the existing tests to verify the change doesn't break anything
Assistant
Let me run all racluster tests to make sure nothing else
Assistant
Let me also run the RayJob and RayService tests
Assistant
Let me run the full racluster and rayjob test suites to make sure nothing is broken
Assistant
Let me run broader tests to ensure nothing else is
Assistant
Let me verify the git diff
Assistant
Let me also check if
UpdatePodSetshas a similar self-referencing issue for standalone RayAssistant
The fix looks correct. Let me run a broader set of tests to make sure everything passes.
Assistant
All tests pass. Let me now do a final verification to confirm the fix is complete and correct.
Assistant
Let me clear the cache and re-run the tests one more
Assistant
All tests pass. Let me submit the changes
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.