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 understand the issue:
- A standalone elastic RayCluster (not part of a RayJob or RayService) is being continuously patched by Kueue.
- The
kueue.x-k8s.io/raycluster-generationannotation tracks the RayCluster's ownmetadata.generation, but remains one value behind. - This creates a self-triggered loop: Kueue reads the RayCluster's generation, writes it back as an annotation, which increments the generation, making the annotation stale, causing another reconcile, etc.
The fix suggested: omit
kueue.x-k8s.io/raycluster-generationwhen thejobObjectis the same standalone RayCluster asrayClusterName.Let me explore the repository structure to understand the codebase.
Assistant
The grep found
/kueue/pkg/controller/jobs/raycluster/common.go. Let me look at that file and also search for the functionGetCustomAnnotationsandGetWorkloadslicingRayClusterCustomAnnotations.Assistant
Let me look at the key files. First, the RayCluster common.go file, and also check if standalone RayCluster has its own `GetCustomAnnotations
Assistant
Let me look at the RayCluster controller file and the common.go file more
Assistant
Let me look at the raycluster_controller.go to see if it has a GetCustomAnnotations method, and also look at common.go around line 335.
Assistant
Let me use the open command correctly.
Assistant
Now let me check the raycluster_controller.go for the GetCustomAnnotations method
Assistant
Let me look at the full raycluster_controller.go and also check how ElasticJob is handled
Assistant
Let me look at the reconciler code around line 962 and also check how the elastic-job annotation is handled
Assistant
Let me check if standalone RayCluster implements
GetCustomAnnotationsthrough some other mechanism, and also look at the elastic jobAssistant
Let me look at the raycluster_webhook.go and also check if RayCluster implements
JobWithCustomAnnotationsAssistant
Let me read the rest of the webhook and check the interface
Assistant
Let me check the interface definition and look for all implementations of
JobWithCustomAnnotationsAssistant
Let me check the
WorkloadSliceEnabledfunction and also see if there's another path that might add customAssistant
Let me look at
WorkloadSliceEnabledand the section of the reconciler around lines 610 and 1434 where it's calledAssistant
Let me look at lines 600-620 in the reconciler
Assistant
Let me look at line 1434 area of the reconciler
Assistant
Let me search for
ElasticWorkloadNameProviderand `GetWorkloadNameExtraPartAssistant
Let me look at the ensurePrebuiltWorkload function to see if there's a path for RayCluster
Assistant
Let me search for all usages of
RayClusterGenerationAnnotationand `RayClusterPodsetReplicaSizesAnnotationAssistant
Let me look at line 1549 area and how the reconciler creates/reconciles workloads for elastic jobs
Assistant
Let me look at the ValidateUpdate handler in the webhook
Assistant
Let me do a broader search to find any code path that could set the raycluster-generation annotation on a standalone RayCluster
Assistant
Let me check what version/branch this repository
Assistant
Let me search for all places where annotations are patched/updated on jobs in the reconciler
Assistant
Let me check all methods on the RayCluster type across all files
Assistant
Now I have a clear picture. Let me look at the
GetWorkloadslicingRayClusterCustomAnnotationsfunction more carefullyAssistant
Let me use the proper command.
Assistant
Let me look at the reconciler around line 955 more carefully to understand the full ensureOneWork
Assistant
Let me look at the main reconcile function to understand the full flow
Assistant
Let me look at
ReconcileGenericJobat line 282.Assistant
Let me continue reading the reconcile function to find the ensureOneWork
Assistant
Let me look at `handleJobWithNoWorkload
Assistant
Let me look at
handleJobWithNoWorkloadAssistant
Let me look at
EnsureWorkloadSlicesin the workloadslicing packageAssistant
Now I understand the issue. The fix should be in
GetWorkloadslicingRayClusterCustomAnnotations- whenjobObjectis the same asrayClusterName, we should omitRayClusterGenerationAnnotationto prevent the self-referencing loop. Let me look at the function one more time and implement the fixAssistant
Now let me look at the tests for this function
Assistant
Let me see the rest of the test function
Assistant
Now I have a clear understanding. The fix should be in
GetWorkloadslicingRayClusterCustomAnnotations- when thejobObjectis the same object as the RayCluster being fetched (same name and namespace), we should omit theRayClusterGenerationAnnotationto prevent a self-referencing loop.Let me implement the fix
Assistant
Let me use the multi-line edit syntax properly.
Assistant
Now let me verify the change compiles and run the relevant tests.
Assistant
Let me configure the Go environment.
Assistant
Build succeeds. Now let me run the tests.
Assistant
All existing tests pass. Let me run all raycluster tests to make sure nothing else is broken.
Assistant
All tests pass. Let me also run the rayjob and rayservice tests since they use
GetWorkloadslicingRayClusterCustomAnnotationsindirectly throughGetCustomAnnotationsAssistant
Let me also run the full test suites for rayjob and raycluster to make sure nothing is broken.
Assistant
All tests pass. Now let me verify the final state of the change.
Assistant
The change looks good. Let me verify once more by running all relevant tests:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.