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
I'll start by exploring the repository structure to understand the codebase and locate the relevant files. Let's first check the current directory.
- Assistant
Let me explore the repository structure more specifically to find the relevant code related to the issue.
- Assistant
Let me look at the common.go file to understand the current implementation:
- Assistant
Now I need to understand the call chain and where
GetWorkloadslicingRayClusterCustomAnnotationsis called. Let me search for usages: - Assistant
Now let me check the raycluster controller and webhook to see how they handle custom annotations:
- Assistant
Let me check the raycluster controller implementation to see how the custom annotations are used:
- Assistant
I see that
RayJobandRayServiceboth haveGetCustomAnnotationsmethods that callGetWorkloadslicingRayClusterCustomAnnotations. But the issue is about standaloneRayCluster. Let me check if the RayCluster controller has a similar method: - Assistant
Let me look at the raycluster controller to find GetCustomAnnotations.
- Assistant
So the RayCluster controller itself doesn't have GetCustomAnnotations? Let me check the raycluster controller implementation more carefully.
- Assistant
Let me check the raycluster_controller.go file to see if it implements GetCustomAnnotations.
- Assistant
I see that
RayClusterimplementsjobframework.GenericJobbut does NOT implementjobframework.JobWithCustomAnnotations. The issue description says that for standalone RayClusters,GetCustomAnnotationscallsGetWorkloadslicingRayClusterCustomAnnotations. Let me check what theGetCustomAnnotationsinterface is and how the generic reconciler uses it. - Assistant
Let me look at the interface definition and the reconciler code to understand how
GetCustomAnnotationsis called. - Assistant
Let me check the raycluster_webhook.go file to see if there's any custom annotation handling.
- Assistant
Let me look at the
reconciler.goto see howGetCustomAnnotationsis called: - Assistant
So I can see that
GetCustomAnnotationsis called in the reconciler when workload slicing is enabled and the job implementsJobWithCustomAnnotations. But theRayClustertype doesn't implement this interface. Let me check if there's a different path for standalone RayClusters. - Assistant
Now I need to understand where
GetCustomAnnotationsis called for theRayClustertype. Let me look at whetherRayClusterimplementsJobWithCustomAnnotations. - Assistant
Let me check if RayCluster implements JobWithCustomAnnotations:
- Assistant
Wait, I see that
RayClusterdoesn't implementJobWithCustomAnnotations. Let me re-read the issue more carefully to understand the path. Let me check how the reconciler is handling this: - Assistant
Wait, let me re-check if RayCluster implements JobWithCustomAnnotations somewhere:
- Assistant
Let me look at where the annotation is being set:
- Assistant
Let me search for how the RayCluster object implements the ElasticWorkloadNameProvider interface.
- Assistant
Let me check if the RayCluster type has a
GetCustomAnnotationsmethod or implementsJobWithCustomAnnotationssomewhere: - Assistant
Let me check the RayCluster controller for any reconciler code:
- Assistant
Let me check if there's a webhook that sets the annotation on update:
- Assistant
Let me look at how the standalone RayCluster is being handled with workload slicing:
- Assistant
Wait, let me look at how
GetCustomAnnotationsis called in the context of standalone RayClusters: - Assistant
Let me look at
JobPodSetsfunction: - Assistant
Wait, let me check the reconciler more carefully to understand what happens with standalone RayClusters and workload slicing. The
GetCustomAnnotationsis only called for jobs that implementJobWithCustomAnnotations, but RayCluster doesn't. Let me look at theensureWorkloadSlicesfunction: - Assistant
Let me look at the
EnsureWorkloadSlicesfunction: - Assistant
Let me look more carefully at how the RayCluster controller is structured and check if it was recently modified:
- Assistant
Let me search more broadly for any
GetCustomAnnotationsmethod onRayCluster: - Assistant
Let me search for all Go files in the raycluster directory more carefully:
- Assistant
Let me look at the git history for changes to the raycluster controller:
- Assistant
Let me look at the issue more carefully. I need to understand the exact call path for standalone RayClusters. Let me check if there's an
ElasticWorkloadNameProviderinterface: - Assistant
Let me look at the reconciler code around where
GetWorkloadNameExtraPartis used: - Assistant
Now let me check if the
RayClustertype implementsElasticWorkloadNameProvider: - Assistant
Wait, let me re-read the issue description more carefully. It says "For standalone RayClusters,
GetCustomAnnotationscallsGetWorkloadslicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name)." But theRayClustertype doesn't implementJobWithCustomAnnotations. Let me check if the RayCluster type has aGetCustomAnnotationsmethod that's been added recently: - Assistant
Let me check if there's another file that may have
GetCustomAnnotationsfor RayCluster: - Assistant
Let me search for any method that could be calling
GetWorkloadslicingRayClusterCustomAnnotationsfor standalone RayClusters: - Assistant
Let me check if there's something in the
raydirectory: - Assistant
Let me look more carefully at the code. Maybe I should look at the
UpdatePodSetsfunction to understand the flow better. Let me also check if there's aGetCustomAnnotationssomewhere else: - Assistant
Let me look more carefully at the full list of methods for RayCluster:
- Assistant
Let me look at the common.go file more closely to understand the flow:
- Assistant
Let me search more comprehensively for all RayCluster methods across all files:
- Assistant
Let me check where
UpdatePodSetsis called from: - Assistant
Let me search for where
GetWorkloadslicingRayClusterCustomAnnotationsis called from non-test code: - Assistant
OK so the problem is clear now. Looking at the code,
GetWorkloadslicingRayClusterCustomAnnotationsis only called byRayJobandRayService, but the issue describes the problem with standaloneRayCluster. Let me look at the issue description again more carefully. The issue says "For standalone RayClusters,GetCustomAnnotationscalls..." but the RayCluster type doesn't implementJobWithCustomAnnotations.Let me look at the
GetWorkloadslicingRayClusterCustomAnnotationsfunction one more time. The key insight is that when this function is called fromRayJob, thejobObjectis the RayJob andrayClusterNameis the name of the underlying RayCluster. For RayService, it's the RayService and the RayCluster name. The annotations are being set on the parent object (RayJob/RayService), which makes sense.But the issue says there's a problem when a standalone RayCluster is used. Looking at the function signature and the issue description, I think the problem might be different from what I initially thought. Let me look more carefully at how the workload name generation works:
- Assistant
Let me check if there's a
GetWorkloadNameExtraPartmethod onRayCluster: - Assistant
Let me check the
WorkloadSliceEnabledfunction and understand the reconciler flow for standalone RayClusters: - Assistant
Let me look at the
WorkloadSliceEnabledfunction: - Assistant
Let me check the test file for
GetWorkloadslicingCustomAnnotationsto understand how it's expected to work: - Assistant
Now I understand the issue. Let me look at how the issue specifically manifests. Let me check if there's a
GetCustomAnnotationsmethod that might be called for RayCluster: - Assistant
Let me look at this from a different angle. Let me search for any place that might set the
RayClusterGenerationAnnotationon a RayCluster: - Assistant
Let me look at the broader picture. Let me understand the
GetCustomAnnotationscall path in the reconciler: - Assistant
Let me check if
RayClusterimplementsElasticWorkloadNameProvider: - Assistant
Let me look at the recent commits to the raycluster controller to understand the context:
- Assistant
Let me look at the key commit that seems related:
80b04a2c8 Generate elastic workload name based on raycluster generation (#9960) - Assistant
Let me understand the issue better. Let me look at the git branches:
- Assistant
Now I understand the issue. Let me re-read the
GetWorkloadslicingRayClusterCustomAnnotationsfunction and think about the fix: - Assistant
Let me check how the reconciler processes a standalone RayCluster more carefully. I need to understand if
GetCustomAnnotationswould be called for standalone RayClusters: - Assistant
Let me look at how the
GetWorkloadslicingRayClusterCustomAnnotationsis called from theRayJobandRayServiceto understand the pattern better: - Assistant
Let me look at this issue from a completely different angle. Let me check if the RayCluster type has
GetCustomAnnotationsin ANY version of the code. The issue says the RayCluster'sGetCustomAnnotationscallsGetWorkloadslicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name). Let me search for all interfaces that RayCluster implements: - Assistant
OK, I think I need to understand the actual problem more carefully. Let me look at the reconciler code where
GetCustomAnnotationsis called and check if there's another path where annotations could be set on the RayCluster: - Assistant
- Assistant
Let me look at this from a different angle. Let me check the
UpdatePodSetsfunction which also callsc.Geton the RayCluster: - Assistant
Now I have a good understanding of the issue. Let me think about this:
The issue describes a problem where a standalone elastic RayCluster has the
raycluster-generationannotation that keeps getting updated, creating a self-referential loop. The fix described is: "omitkueue.x-k8s.io/raycluster-generationwhen thejobObjectis the same standalone RayCluster asrayClusterName."The
GetWorkloadslicingRayClusterCustomAnnotationsfunction is called fromRayJob.GetCustomAnnotationsandRayService.GetCustomAnnotations. For those cases,jobObjectis the RayJob/RayService andrayClusterNameis the name of the underlying RayCluster - different objects. But the function should also handle the case wherejobObjectIS the RayCluster itself (standalone case).Let me check the reconciler flow once more:
- Assistant
Let me check the current git version:
- Assistant
Let me look at the exact scenario the issue describes. Let me search for the flow where a standalone RayCluster gets the
raycluster-generationannotation. Maybe the issue is that theGetWorkloadslicingRayClusterCustomAnnotationsfunction is called somewhere else: - Assistant
OK, I now understand the issue. Looking at the
GetWorkloadslicingRayClusterCustomAnnotationsfunction, it fetches the RayCluster byrayClusterNameand sets its generation as an annotation onjobObject. WhenjobObjectis the same RayCluster (standalone case), this creates a self-update loop because setting the annotation changes the object's generation, making the annotation stale again.The fix is to check if
jobObjectis the same standalone RayCluster asrayClusterName, and if so, skip theRayClusterGenerationAnnotation. Let me implement this: - Assistant
Let me scroll down to the
GetWorkloadslicingRayClusterCustomAnnotationsfunction. - Assistant
Now I understand the issue clearly. Looking at the
GetWorkloadslicingRayClusterCustomAnnotationsfunction:-
It's called from
RayJob.GetCustomAnnotationsandRayService.GetCustomAnnotations- in those cases,jobObjectis the RayJob/RayService, andrayClusterNameis the name of the underlying RayCluster (different object). -
For standalone RayClusters, if
GetCustomAnnotationswere called (which the issue describes happening in v0.16.5),jobObjectwould be the RayCluster itself andrayClusterNamewould be the RayCluster's own name. This creates a self-update loop:- Fetch RayCluster → get generation N
- Set annotation
raycluster-generation: "N"on the same RayCluster - Patch advances generation to N+1
- Next reconcile: annotation is stale (N != N+1) → repeat
The fix is to check if
jobObjectis the same standalone RayCluster as the one being fetched byrayClusterName, and if so, omit theRayClusterGenerationAnnotation.Let me implement the fix:
-
- Assistant
Good, the change is in place. Now let me verify the change by looking at the updated function:
- Assistant
Now let me run the existing tests to make sure they still pass:
- Assistant
Let me set up the Go environment:
- Assistant
Let me set up the Go environment properly.
- Assistant
Good, existing tests pass. Now let me run all tests in the raycluster package:
- Assistant
All tests pass. Now let me also run the tests for the RayJob controller since it also calls
GetWorkloadslicingRayClusterCustomAnnotations: - Assistant
Let me also run the RayService tests:
- Assistant
Let me verify that all tests pass for the raycluster package:
- Assistant
Let me also run the complete test suite to see the final result:
- Assistant
All tests pass. Let me also run the rayjob and rayservice tests:
- Assistant
Let me verify the diff of my change:
- Assistant
The change looks correct. Let me also run a broader set of tests to make sure nothing else is broken:
- Assistant
Let me also run the workloadslicing tests:
- Assistant
Let me also run the jobframework tests to ensure no regressions:
- Assistant
All tests pass. Let me do a final review of the complete change:
- Assistant
Now let me verify the final state of the file to make sure it looks correct:
- Assistant
Let me run a final comprehensive test to make sure everything is working:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.