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
Let me start by understanding the issue:
- A standalone elastic RayCluster managed by Kueue is continuously being updated by Kueue because of the
kueue.x-k8s.io/raycluster-generationannotation. - The annotation tracks the RayCluster's own
metadata.generation, but since writing the annotation increases the generation, it creates an infinite loop. - The fix is to omit
kueue.x-k8s.io/raycluster-generationwhen thejobObjectis the same standalone RayCluster asrayClusterName.
Let me explore the repository structure to understand the codebase.
- A standalone elastic RayCluster managed by Kueue is continuously being updated by Kueue because of the
Assistant
The grep found a file. Let me look at that file and related files.
Assistant
Only one place defines this constant. Let me look at the common.go file and then find where it's used.
Assistant
Let me look at the common.go file, focusing on the relevant
Assistant
Let me use bash to read the file.
Assistant
Now let me look at where
GetWorkloadslicingRayClusterCustomAnnotationsis called and how it relates to theGetCustomAnnotationsfunctionAssistant
Let me search more broadly for
GetCustomAnnotationsin the raycluster package.Assistant
Let me find the raycluster controller file.
Assistant
Let me find where GetCustomAnnotations is defined. It might be in the raycluster_controller.go, or it might be inherited from a generic job framework.
Assistant
Not in the raycluster directory. Let me search more broadly.
Assistant
Let me check the RayCluster controller to see if it has its own GetCustomAnnotations
Assistant
Now let me look at the RayJob and RayService GetCustomAnnotations implementations.
Assistant
Now let me also look at RayService.
Assistant
Let me look at the reconciler to understand how GetCustomAnnotations is called.
Assistant
Let me check if RayCluster implements GetCustomAnnotations anywhere or if there's a default behavior.
Assistant
Let me search more broadly for GetCustomAnnotations implementations
Assistant
Let me look at the JobWithCustomAnnotations interface and the reconciler more carefully.
Assistant
Let me check the recent git changes to understand what's happening.
Assistant
Let me search more broadly for any
GetCustomAnnotationsrelated to RayCluster.Assistant
Let me look at the RayCluster struct definition.
Assistant
Let me look at the reconciler code around where the custom annotations are applied.
Assistant
Let me search the entire codebase for any method on RayCluster that calls GetWorkloadslicingRayClusterCustomAnnotations.
Assistant
Let me check if the RayCluster implements GetWorkloadNameExtraPart.
Assistant
Let me check where GetWorkloadNameExtraPart is used and if the RayCluster implements ElasticWorkloadNameProvider.
Assistant
Let me search for where the annotation is being written on the RayCluster object.
Assistant
Let me look at WorkloadSliceEnabled.
Assistant
Let me look at the reconciler code around where
WorkloadSliceEnabledis used and annotations might be patched.Assistant
Let me find where UpdatePodSets is called.
Assistant
Let me look at the JobPodSets function.
Assistant
Let me look at the RayCluster webhook to check if there's a path that patches annotations.
Assistant
Let me look at the reconciler function around where
ensurePrebuiltWorkloadorensureOneWorkloadis called to understand the full flow.Assistant
Let me look at
constructWorkload- this is where the annotations might be set.Assistant
Let me look at the constructWorkload function.
Assistant
Let me look at the main reconcile function flow.
Assistant
Let me look at handleJobWithNoWorkload.
Assistant
Let me read handleJobWithNoWorkload.
Assistant
Let me search one more time VERY carefully for any GetCustomAnnotations on the RayCluster.
Assistant
Let me search the entire repository again more carefully.
Assistant
Let me look at the test file for common.go.
Assistant
Let me check the interface assertions for the RayCluster type.
Assistant
Let me check if there's a
GetCustomAnnotationson any embedded or shared type that the RayCluster might inherit.Assistant
Let me read the full interface file around the comment about RayCluster.
Assistant
Let me look at the reconciler at line 1434.
Assistant
Let me look at ensurePrebuiltWorkload function more carefully.
Assistant
Let me look at ensurePrebuiltWorkloadInSync.
Assistant
Let me check the entire raycluster package for any method definitions.
Assistant
Now I have a clear understanding of the issue. Let me implement the fix.
The problem is in
GetWorkloadslicingRayClusterCustomAnnotations: when called with a standalone RayCluster as bothjobObjectand the targetrayClusterName, it fetches the same RayCluster's generation, writes it back as an annotation, which increments the generation, making the annotation stale again — creating an infinite loop.The fix: skip returning
RayClusterGenerationAnnotationwhenjobObject.GetName() == rayClusterName(i.e., the jobObject IS the same RayCluster).Let me first create a reproduction script to understand the problem better, then apply the fix.
Assistant
Let me set up the Go environment.
Assistant
Let me find the correct test name.
Assistant
Let me run the correct test.
Assistant
Now let me apply the fix. I'll modify
GetWorkloadslicingRayClusterCustomAnnotationsto omitRayClusterGenerationAnnotationwhenjobObjectis the same as the RayCluster being referenced.Assistant
Let me use the open command correctly.
Assistant
Let me check how
mergeAnnotationsworks and how the annotations map is handled.Assistant
Let me look at
mergeAnnotationsAssistant
Now I understand the full picture. Let me apply the fix. When
jobObject.GetName() == rayClusterName, the jobObject IS the same RayCluster, so writing its generation back as an annotation creates a self-updating loop. The fix is to not includeRayClusterGenerationAnnotationin this case.Assistant
Let me try a different approach with the replace command.
Assistant
Let me verify the change.
Assistant
Good. Now let me run the tests to make sure everything passes.
Assistant
Good, it compiles. Let me run the tests.
Assistant
All tests pass. Let me also run tests for the related packages that use this function.
Assistant
Let me also run the RayService tests.
Assistant
Let me also check that the reconciler tests pass.
Assistant
All tests pass. Let me verify the diff of my change.
Assistant
The change looks correct. Let me also create a quick test script to verify the fix logic works as expected, then clean up.
Assistant
Let me write a quick test to verify the fix handles the standalone RayCluster case correctly.
Assistant
Let me clean up and make sure the fix is ready.
Assistant
Let me run the full test suite for all affected packages one final time.
Assistant
Let me also run the workloadslicing tests.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.