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 Kueue continuously patches standalone elastic RayClusters with their own generation number, creating an infinite loop.
- The
kueue.x-k8s.io/raycluster-generationannotation is written back onto the RayCluster, but this patch advances the RayCluster'smetadata.generation, making the annotation stale again. - The fix should be to omit
kueue.x-k8s.io/raycluster-generationwhen thejobObjectis the same standalone RayCluster asrayClusterName.
Let me first explore the repository structure to understand the codebase.
Assistant
The repository structure is a Kubernetes controller (Kueue). Let me search for the relevant files mentioned in the issue:
GetCustomAnnotationsandGetWorkloadSlicingRayClusterCustomAnnotations.Assistant
Let me also search for the
GetWorkloadSlicingRayClusterCustomAnnotationsfunction:Assistant
The function might have a different name. Let me search for related terms.
Assistant
Let me look at the relevant files to understand the code structure.
Assistant
Now let me look at the
GetCustomAnnotationsfunction in the raycluster controller:Assistant
Now let me check the jobframework interface and reconciler to understand how
GetCustomAnnotationsis called.Assistant
Now let me look at the reconciler to see how
GetCustomAnnotationsis called.Assistant
Let me search for where
GetCustomAnnotationsis called:Assistant
Let me look at the context around line 962 to understand how GetCustomAnnotations is called.
Assistant
Now let me see how RayJob implements
GetCustomAnnotations:Assistant
Now let me check if the RayCluster itself implements
JobWithCustomAnnotations:Assistant
Let me search for GetCustomAnnotations implementations more broadly:
Assistant
Now let me look at the
GetWorkloadslicingRayClusterCustomAnnotationsfunction more closely and understand the issue:Assistant
Let me look more carefully at the
GetWorkloadslicingRayClusterCustomAnnotationsfunction:Assistant
Let me now search for where RayCluster implements the
GetCustomAnnotationsinterface:Assistant
Let me check if there's a way for RayCluster itself to implement
GetCustomAnnotations:Assistant
Let me search for where
GetWorkloadslicingRayClusterCustomAnnotationsis called:Assistant
Let me search more broadly for any GetCustomAnnotations implementation that might use
j.Name:Assistant
Let me search for any interface implementation in raycluster that involves custom annotations:
Assistant
Let me look at how the RayCluster controller might call the
GetWorkloadslicingRayClusterCustomAnnotationsfunction. I need to understand where the RayCluster itself uses its own name asrayClusterName:Assistant
I see that the RayCluster doesn't implement
GetCustomAnnotationsdirectly. Let me check if there's something else going on. Let me look at how RayJob's GetCustomAnnotations is called to understand the flow better.The issue says:
- 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.
But I don't see a
GetCustomAnnotationsimplementation for RayCluster. Let me search more carefully.- For standalone RayClusters,
Assistant
Let me look more carefully at the code. Maybe there's a new method I'm missing. Let me check the full test file to understand the expected behavior:
Assistant
Let me check if there's a
GetCustomAnnotationsimplementation that was recently added to RayCluster:Assistant
Let me search for where RayCluster might call GetCustomAnnotations. The issue says that for standalone RayClusters,
GetCustomAnnotationscallsGetWorkloadSlicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name). Let me search for this pattern.Assistant
Let me look at the issue description again more carefully. It mentions that
GetCustomAnnotationscallsGetWorkloadSlicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name). I need to find where this call originates for RayCluster.The issue also says: "For standalone RayClusters,
GetCustomAnnotationscallsGetWorkloadSlicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name)."This suggests there might be a
GetCustomAnnotationsimplementation for RayCluster that passesj.NameasrayClusterName. Let me search more broadly.Wait, looking at the code again, I don't see
GetCustomAnnotationsimplemented for RayCluster. But the issue clearly says it happens. Let me check if perhaps there's an interface implementation in a different file or if the RayCluster gets this interface through some other mechanism.Let me look at the raycluster controller file more carefully:
Assistant
Let me search more thoroughly for where
GetCustomAnnotationsmight be called for RayCluster:Assistant
Let me look at the webhook or other files related to RayCluster to see if there's a GetCustomAnnotations being set up there.
Actually, wait - looking back at the issue description more carefully:
For standalone RayClusters,
GetCustomAnnotationscallsGetWorkloadSlicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name).The issue says
j.Nameis passed as the rayClusterName. This suggests the implementation passes the RayCluster's own name to fetch itself.Let me check if there's a separate file that handles this.
Assistant
I need to find where the RayCluster is implementing GetCustomAnnotations. Let me look at the webhook file and any other files in the raycluster package.
Assistant
Assistant
Let me search for where GetCustomAnnotations is implemented.
Assistant
Assistant
Let me search for where GetCustomAnnotations might be implemented for RayCluster.
Assistant
Assistant
Let me search for CustomAnnotations in the raycluster package.
Assistant
Let me look at the test file to understand the expected behavior better:
Assistant
Let me search more broadly for where GetCustomAnnotations might be implemented for RayCluster:
Assistant
Let me check the current git status and look for any recent changes:
Assistant
Let me check the interface definition more closely and look for any RayCluster implementation I might have missed:
Assistant
Based on my investigation, I understand the issue now:
- The
GetWorkloadslicingRayClusterCustomAnnotationsfunction is used by RayJob and RayService to get the RayCluster's generation annotation - When this function is called with
rayClusterNamepointing to the same object asjobObject(i.e., a standalone RayCluster), it fetches the RayCluster, gets its generation, and writes it back as an annotation - This patch advances the RayCluster's
metadata.generation, making the annotation stale - This creates an infinite loop of self-updates
The fix is to omit the
raycluster-generationannotation when thejobObjectis the same object as therayClusterNamebeing fetched (i.e., when it's a standalone RayCluster writing to itself).Let me implement the fix:
- The
Assistant
Let me use the correct syntax to open the file.
Assistant
Now I understand the issue. The
GetWorkloadslicingRayClusterCustomAnnotationsfunction fetches a RayCluster and writes its generation back as an annotation. For RayJob/RayService, this is correct - they're setting the RayCluster's generation as an annotation on themselves. But if a standalone RayCluster implementsGetCustomAnnotations(passingj.NameasrayClusterName), it would write its own generation back to itself, causing an infinite update loop.The fix is to skip setting the
raycluster-generationannotation whenrayClusterNameis the same as thejobObject's name (meaning they're the same object).Assistant
Now I understand the issue. The
GetWorkloadslicingRayClusterCustomAnnotationsfunction writes the RayCluster's generation back as an annotation. For a standalone RayCluster that implementsGetCustomAnnotations(passing its own name asrayClusterName), this creates an infinite self-update loop because:- The annotation is written with the current generation N
- The patch advances the RayCluster's generation to N+1
- The annotation becomes stale (shows N, but generation is N+1)
- Next reconcile writes the new generation N+1 as the annotation
- And so on...
The fix is to skip setting
RayClusterGenerationAnnotationwhenrayClusterNamematches thejobObject's name (i.e., when it's a standalone RayCluster writing to itself).Assistant
Let me use sed to edit the file directly:
Assistant
I need to modify the code to add a check before setting
rayClusterGeneration. Let me use sed to make the change.Assistant
Now I'll make the edit using sed:
Assistant
Let me check the file:
Assistant
The sed command messed up the file. Let me restore it and try a different approach.
Assistant
Let me verify the file is restored:
Assistant
Good, the file is restored. Now let me use the
editcommand properly:Assistant
Let me create a temporary script to apply the fix properly:
Assistant
Let me verify the fix was applied correctly:
Assistant
The fix has been applied. Now let me verify the code compiles and run the existing tests.
Assistant
The build failed because GOCACHE is not defined. Let me try setting it up properly.
Assistant
The code compiles. Now let me run the existing tests to ensure the fix doesn't break anything.
Assistant
Assistant
Let me run the tests in the raycluster package to make sure everything passes.
Assistant
All raycluster tests pass. Let me also run the RayJob and RayService tests since they use the same
GetWorkloadslicingRayClusterCustomAnnotationsfunction:Assistant
All tests pass. Let me verify the diff of my changes:
Assistant
The fix has been applied and all tests pass. Let me summarize what was done:
Summary
Issue: A standalone Kueue-managed elastic RayCluster was continuously self-updating with its own generation annotation (
kueue.x-k8s.io/raycluster-generation). This happened because:- The annotation was written with the current generation N
- The patch advanced the RayCluster's
metadata.generationto N+1 - The annotation became stale (showing N but generation was N+1)
- The next reconcile wrote the new generation N+1, and the cycle continued
Fix: In
GetWorkloadslicingRayClusterCustomAnnotations, I added a check to skip setting theraycluster-generationannotation whenrayClusterNameequalsjobObject.GetName(). This means:- For RayJob/RayService: The annotation is still set correctly since
rayClusterName(the underlying RayCluster name) is different fromjobObject.GetName()(the RayJob/RayService name). - For standalone RayClusters: The annotation is skipped since would be the RayCluster's own name, preventing the self-update loop.
Assistant
The fix has been successfully applied. 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.