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 analyze the issue:
- The problem is that a standalone elastic RayCluster is continuously being updated by Kueue
- The
kueue.x-k8s.io/raycluster-generationannotation is being set to the RayCluster's own generation, but it remains one value behind because every time the annotation is written, it updates the RayCluster, advancing its generation - This creates a self-triggered loop
- The fix should be to omit
kueue.x-k8s.io/raycluster-generationwhen thejobObjectis the same standalone RayCluster asrayClusterName
Let me start by exploring the repository structure to understand the codebase.
Assistant
Let me search for the specific function mentioned in the issue:
GetWorkloadSlicingRayClusterCustomAnnotationsorGetCustomAnnotations.<tool_call> <function=bash_terminal> <parameter=command> grep -r "GetWorkloadSlicingRayClusterCustomAnnotations|raycluster-generation" /kueue --include="*.go" -l </tool_call>
Assistant
The user wants me to search for files containing specific terms related to the issue. I need to use the bash_terminal tool to run grep commands. Let me search for the function mentioned in the issue.
Assistant
Let me explore the relevant file to understand the code structure.
Assistant
Let me examine the relevant files to understand the code structure.
Assistant
Now let me look at the RayJob's GetCustomAnnotations implementation:
Assistant
Let me look at the RayCluster controller to see if there's a GetCustomAnnotations implementation:
Assistant
Now let me look at the jobframework reconciler to understand how GetCustomAnnotations is called:
Assistant
Now I need to understand the issue better. Let me look at the context around line 962 in the reconciler to understand how GetCustomAnnotations is called.
Assistant
Let me check the RayService controller:
Assistant
Let me look for the interface definition and also check if there's a separate file with GetCustomAnnotations for RayCluster:
Assistant
Let me look at all files in the raycluster package to see if there's an implementation I'm missing:
Assistant
Let me look at the tests to understand better:
Assistant
Assistant
The user wants me to search for
RayCluster.*GetCustomAnnotationsorRayCluster.*JobWithCustomAnnotationsin the codebase.Assistant
The issue is clear now. The problem is in the
GetWorkloadslicingRayClusterCustomAnnotationsfunction. When a standalone RayCluster is managed by Kueue with elastic jobs via workload slices, and if that RayCluster also implementsJobWithCustomAnnotations, the function gets called withjobObjectbeing the RayCluster itself andrayClusterNamebeing the RayCluster's own name. This creates a self-triggered loop because:- The function fetches the RayCluster and gets its generation
- It returns annotations including the
RayClusterGenerationAnnotationwith that generation - The reconciler patches the RayCluster with these annotations
- This advances the RayCluster's generation
- Next reconcile, the same thing happens again
The fix is to omit the
RayClusterGenerationAnnotationwhen thejobObjectis the same standalone RayCluster asrayClusterName.Let me implement this fix:
Assistant
Let me find the exact location of the
GetWorkloadslicingRayClusterCustomAnnotationsfunction and understand its structure better.Assistant
Now I need to view the full
GetWorkloadslicingRayClusterCustomAnnotationsfunction to understand what I need to modify.Assistant
Now I understand the issue. The function
GetWorkloadslicingRayClusterCustomAnnotationsis called by RayJob and RayService (wherejobObjectis different fromrayClusterName), but if a standalone RayCluster also implements this interface (which can happen), it would passj.Object()andj.Name, making them the same object. This creates a self-triggered loop because:- The function fetches the RayCluster and gets its generation
- It returns annotations including the
RayClusterGenerationAnnotationwith that generation - The reconciler patches the RayCluster with these annotations
- This advances the RayCluster's generation
- Next reconcile, the same thing happens again
The fix is to omit the
RayClusterGenerationAnnotationwhen thejobObjectis the same as therayClusterName.Let me implement this fix:
Assistant
Now I need to modify the
GetWorkloadslicingRayClusterCustomAnnotationsfunction to check if thejobObjectis the same as therayClusterName, and if so, skip setting theRayClusterGenerationAnnotation.The fix should be to add a condition before setting
rayClusterGeneration:} else { // Skip setting the generation annotation for standalone RayClusters // to avoid a self-triggered update loop. if jobObject.GetName() != rayClusterName { rayClusterGeneration = strconv.FormatInt(rayClusterObj.GetGeneration(), 10) } }This way, when a standalone RayCluster calls this function (where
jobObjectis the RayCluster itself andrayClusterNameis also the RayCluster's name), therayClusterGenerationwill remain empty and won't be set on the RayCluster.Let me implement this fix.
Assistant
Now I need to modify line 353 to add a condition before setting the rayClusterGeneration. The fix is to check if
jobObject.GetName() != rayClusterNamebefore setting the generation.Let me look at the exact lines I need to modify:
- Line 352:
} else { - Line 353:
rayClusterGeneration = strconv.FormatInt(rayClusterObj.GetGeneration(), 10) - Line 354:
}
I need to change lines 352-354 to:
} else { // Skip setting the generation annotation for standalone RayClusters // to avoid a self-triggered update loop. if jobObject.GetName() != rayClusterName { rayClusterGeneration = strconv.FormatInt(rayClusterObj.GetGeneration(), 10) } }Let me use the edit command to make this change.
- Line 352:
Assistant
Let me apply the fix by editing the
GetWorkloadslicingRayClusterCustomAnnotationsfunction incommon.go:Assistant
I need to edit the file to add a condition that checks if the jobObject is the same as the rayClusterName before setting the rayClusterGeneration. The fix should be on line 353.
Let me use the edit command to modify the code.
Assistant
I need to use the correct syntax for the edit command. Let me fix this.
Assistant
Now I can see the full file. I need to modify line 353 in the
GetWorkloadslicingRayClusterCustomAnnotationsfunction to add a condition that checks if the jobObject is the same as the rayClusterName before setting the rayClusterGeneration.Assistant
Let me check if the edit worked correctly:
Assistant
The edit worked, but the indentation looks incorrect. Let me check the full function and fix the indentation:
Assistant
The indentation is incorrect. Let me fix it by rewriting the function properly:
Assistant
The indentation is incorrect. Let me fix it properly using the edit command.
Assistant
The user is getting an error because the open command was not properly formatted. I need to use the correct format for the tool call. Let me fix this.
Assistant
Let me fix the indentation issue by rewriting the function properly:
Assistant
Let me restore the original file and apply the fix correctly:
Assistant
Let me check the current state of the file and apply the fix with proper indentation:
Assistant
Now let me apply the fix with proper indentation. I need to replace the
} else {block to include a check before setting the generation:Assistant
Let me verify the fix was applied correctly:
Assistant
The fix looks good. Let me verify the code compiles correctly:
Assistant
I need to set the GOCACHE environment variable. Let me try again.
Assistant
The code compiles correctly. Now let me run the existing tests to make sure the fix doesn't break anything.
Assistant
Let me run all the tests for the raycluster package:
Assistant
All tests pass. Let me also run the RayJob tests to make sure the fix doesn't break anything there:
Assistant
All tests pass. Let me now view the complete diff to make sure the fix is correct:
Assistant
The fix looks correct. Let me also run the RayService tests to make sure nothing is broken there:
Assistant
All tests pass. Let me also run a broader set of tests to make sure nothing else is broken:
Assistant
All tests pass. Let me now run the complete test suite for the ray-related packages to ensure everything is working:
Assistant
All tests pass. Let me verify the complete fix one more time:
Assistant
All tests pass. Let me submit the solution now.
Summary of the fix:
The issue was that a standalone elastic RayCluster was continuously being updated by Kueue because the
kueue.x-k8s.io/raycluster-generationannotation was being set to the RayCluster's own generation. This caused a self-triggered update loop:- The
GetWorkloadslicingRayClusterCustomAnnotationsfunction fetched the RayCluster and got its generation - It returned annotations including the
RayClusterGenerationAnnotationwith that generation - The reconciler patched the RayCluster with these annotations
- This advanced the RayCluster's generation, making the annotation stale again
- Next reconcile, the same thing happened again
The fix: Added a condition to skip setting the
RayClusterGenerationAnnotationwhen thejobObject(the object callingGetCustomAnnotations) is the same as therayClusterName(the RayCluster being referenced). This prevents standalone RayClusters from writing their own generation back onto themselves, while still allowing RayJob and RayService to set the RayCluster's generation on themselves (which is the correct behavior for those use cases).- The
Assistant
The user wants me to submit my solution. I need to use the submit command correctly. Let me call it with proper syntax.
Assistant
The user is trying to submit their solution. They need to call the submit command properly. Let me try to submit the changes.
Assistant
Let me verify the fix is correct and then submit:
Assistant
I have made the necessary fix to resolve the issue. Let me summarize what was done:
Summary
Issue: A standalone elastic RayCluster was continuously being updated by Kueue because the
kueue.x-k8s.io/raycluster-generationannotation was being set to the RayCluster's own generation, creating a self-triggered update loop.Root Cause: In the
GetWorkloadslicingRayClusterCustomAnnotationsfunction, when a standalone RayCluster implements theJobWithCustomAnnotationsinterface, it would call this function withjobObjectbeing the RayCluster itself andrayClusterNamealso being the RayCluster's name. This caused the function to always set the RayCluster's generation on itself, which would advance the generation, making the annotation stale on the next reconcile.Fix: Added a condition in
pkg/controller/jobs/raycluster/common.goto skip setting theRayClusterGenerationAnnotationwhenjobObject.GetName() != rayClusterNameis false (i.e., when the job object is the same as the RayCluster being referenced). This prevents the self-triggered loop for standalone RayClusters while still allowing RayJob and RayService to correctly set the RayCluster's generation on themselves.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.