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 standalone elastic RayClusters are being continuously updated by Kueue because the
raycluster-generationannotation is tracking the RayCluster's ownmetadata.generation, creating a self-triggered loop.The fix should be to omit the
kueue.x-k8s.io/raycluster-generationannotation when thejobObjectis the same standalone RayCluster as therayClusterName.Let me start by exploring the repository structure and finding the relevant code.
- Assistant
Let me examine this file.
- Assistant
Let me continue reading the file to find the relevant functions.
- Assistant
Let me continue reading to find the
GetCustomAnnotationsandGetWorkloadslicingRayClusterCustomAnnotationsfunctions. - Assistant
Let me continue reading the rest of the file.
- Assistant
Now I can see the
GetWorkloadslicingRayClusterCustomAnnotationsfunction (lines 335-366). Let me find whereGetCustomAnnotationsis called to understand the full picture. - Assistant
Let me check the RayCluster controller to see how it implements GetCustomAnnotations.
- Assistant
Let me check the RayCluster controller to see how it implements GetCustomAnnotations.
- Assistant
Let me look for GetCustomAnnotations in the raycluster package more broadly.
- Assistant
Let me search for it in the rayjob and rayservice controllers.
- Assistant
Let me look at the RayJob GetCustomAnnotations implementation.
- Assistant
Now let me look at the RayCluster controller to find how it implements GetCustomAnnotations.
- Assistant
Let me continue reading the RayCluster controller.
- Assistant
The RayCluster controller doesn't seem to implement GetCustomAnnotations. Let me check the interface and the reconciler to see how it works.
- Assistant
Now let me check the interface to understand what happens when
GetCustomAnnotationsis not implemented. - Assistant
Let me check the interface definition to understand GetCustomAnnotations better and see the optional interface pattern.
- Assistant
Let me search more carefully for how standalone RayCluster could be calling GetCustomAnnotations.
- Assistant
Let me look at the reconciler to see how GetCustomAnnotations is called and how it relates to the issue.
- Assistant
Let me check the context around that line.
- Assistant
Let me search more carefully to understand if there's a different code path for standalone RayClusters.
- Assistant
Let me look at the RayService controller to see how it implements GetCustomAnnotations.
- Assistant
Let me look at how workload slicing is handled and whether there's a different code path for standalone RayClusters.
- Assistant
Let me look at the workload slicing code.
- Assistant
Let me look at how
RayClusterGenerationAnnotationis read and used. - Assistant
Let me search for where the annotation might be set on standalone RayClusters.
- Assistant
Let me look at the webhook code for RayCluster.
- Assistant
Let me continue reading the webhook code.
- Assistant
Let me now look at the reconciler code more carefully to understand the flow for standalone RayClusters.
- Assistant
Let me check what
WorkloadSliceEnableddoes. - Assistant
Let me see what
WorkloadSliceEnableddoes. - Assistant
Let me look at the
mergeAnnotationsfunction to understand how annotations are merged. - Assistant
Let me look at the test file for
GetWorkloadslicingRayClusterCustomAnnotationsto understand the expected behavior. - Assistant
Let me look at the test file.
- Assistant
Let me look at the test for
GetWorkloadslicingCustomAnnotations. - Assistant
Let me continue reading the test file.
- Assistant
Let me look at the git history to understand recent changes that might be related to this issue.
- Assistant
Let me search for recent changes related to the RayCluster generation annotation.
- Assistant
Let me look at the commit that added generation-based elastic workload names.
- Assistant
Let me see what this commit changed.
- Assistant
Let me see the changes in common.go from this commit.
- Assistant
Let me search for all methods on the RayCluster type to see if I missed
GetCustomAnnotations. - Assistant
Let me look at the
ensurePrebuiltWorkloadfunction more carefully to understand the full flow. - Assistant
Let me look at the
GetWorkloadNameExtraPartfunction implementation in the RayCluster controller. - Assistant
Hmm, the RayCluster doesn't implement
GetWorkloadNameExtraParteither. Let me search more broadly. - Assistant
Let me look at all the methods on
RayClusterin all files. - Assistant
Let me look at how
ElasticWorkloadNameProvideris used in the reconciler. - Assistant
Let me look at this code in context.
- Assistant
Let me look at the
EnsureWorkloadSlicesfunction to see if there's something there that might cause the annotation to be set. - Assistant
Let me look at the
EnsureWorkloadSlicesfunction. - Assistant
Let me look more carefully at what happens when a standalone RayCluster is reconciled. Let me also check if there's something in the
ensureOneWorkloadpath that might handle annotations. - Assistant
Let me look at the ReconcileGenericJob function.
- Assistant
Let me continue reading the ReconcileGenericJob function.
- Assistant
Let me look at how the RayCluster reconciler is set up to understand the flow for standalone RayClusters.
- Assistant
Let me look at
NewGenericReconcilerFactoryto understand how it works. - Assistant
Let me look at the git history to see if there's a recent change that added
GetCustomAnnotationsto RayCluster. - Assistant
Let me try a different search to understand the issue.
- Assistant
Let me re-examine the issue. I need to understand how a standalone RayCluster might be getting its
raycluster-generationannotation set. Let me look at whether there might be aGetCustomAnnotationsimplementation that was added or expected to be added. - Assistant
Let me look at the issue from a different angle. Let me check if there's a
GetCustomAnnotationsmethod that might be implemented through an embedded type or interface. - Assistant
Let me look at the ensurePrebuiltWorkload function and the workload slicing path more carefully.
- Assistant
Now I understand the issue. Let me look at the
GetWorkloadslicingRayClusterCustomAnnotationsfunction one more time and implement the fix. - Assistant
Now I have a clear understanding of the issue. Let me implement the fix. The issue is in the
GetWorkloadslicingRayClusterCustomAnnotationsfunction. WhenjobObjectis the same standalone RayCluster asrayClusterName, the function should skip theraycluster-generationannotation because it creates a self-updating loop.Let me implement the fix:
- Assistant
Now let me verify whether the RayCluster type implements
JobWithCustomAnnotationsby checking the interface assertions. - Assistant
Let me check if there's a different version of the code on the release-0.16 branch.
- Assistant
Let me check the tags.
- Assistant
Let me look at the test file for the RayCluster controller to see if there's something about custom annotations.
- Assistant
Let me check all files in the raycluster package for any GetCustomAnnotations.
- Assistant
Now I understand the issue. The
GetWorkloadslicingRayClusterCustomAnnotationsfunction is called for both RayJob and RayService, but the issue describes a scenario where a standalone RayCluster (wherejobObjectIS the same RayCluster asrayClusterName) would cause a self-updating loop. The fix is to skip theraycluster-generationannotation when the jobObject is the same RayCluster as the one being fetched.Let me implement the fix:
- Assistant
Wait, I notice the namespace check is redundant -
jobObject.GetNamespace() == jobObject.GetNamespace()is always true. Let me fix that. - Assistant
Good. Now let me verify the file compiles correctly.
- Assistant
Let me set the GOCACHE and HOME environment variables.
- Assistant
The Go syntax for the multi-value assignment in the expression doesn't work that way. Let me fix it.
- Assistant
I see there's a duplicate comment block. Let me fix it.
- Assistant
Good. Now let me compile to check for syntax errors.
- Assistant
The code compiles. Now let me run the existing tests for the raycluster package.
- Assistant
All existing tests pass. Let me run all the tests in the raycluster package.
- Assistant
All tests pass. Let me also run the tests for the RayJob and RayService controllers since they also use
GetWorkloadslicingRayClusterCustomAnnotations. - Assistant
Good. Let me also run the RayService tests.
- Assistant
All tests pass. Let me also run the workload slicing tests.
- Assistant
All tests pass. Let me also run the jobframework tests to make sure nothing is broken.
- Assistant
All tests pass. Now let me review the final state of my change.
- Assistant
The change looks correct. Let me verify the final state of the function.
- Assistant
Let me use the correct syntax.
- Assistant
The change looks correct. Let me also run a broader build to make sure nothing is broken across the entire project.
- Assistant
The entire project builds successfully. Let me run a broader set of tests related to the change.
- Assistant
All tests pass. Let me now review the change one more time to make sure it's correct and complete.
- Assistant
The change is minimal and focused. Let me now verify the full diff one more time before submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.