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 exploring the repository structure to understand the codebase and find the relevant files mentioned in the issue.
Assistant
Let me make a single tool call first.
Assistant
Let me look at the common.go file in the raycluster package which seems most relevant.
Assistant
Now let me look at how
GetCustomAnnotationsis used in the raycluster controller and where it callsGetWorkloadslicingRayClusterCustomAnnotations.Assistant
Let me look at the RayJob and RayService controllers to understand how they call the function, and look at the raycluster controller to see how the standalone RayCluster works.
Assistant
Now let me look at how the standalone RayCluster controller works. Let me check the raycluster_controller.go for any custom annotations or generation handling.
Assistant
The standalone RayCluster doesn't seem to define its own
GetCustomAnnotations. Let me look at the full controller file.Assistant
The standalone RayCluster controller doesn't define its own
GetCustomAnnotations. Let me check the interface and the reconciler usage, and also the git history for the changes from #10160.Assistant
Let me search more broadly for where the standalone RayCluster might implement
GetCustomAnnotationsorGetWorkloadNameExtraPart.Assistant
The current HEAD doesn't have
GetCustomAnnotationson the standalone RayCluster. The issue is about v0.16.5. Let me check the release-0.16 branch.Assistant
Let me look at the commit that introduced the generation-based elastic workload names.
Assistant
Let me look at how the reconciler invokes
GetCustomAnnotationsand the broader context.Assistant
Let me look at the full raycluster_controller.go to understand the current standalone RayCluster implementation.
Assistant
The standalone RayCluster in the current HEAD doesn't implement
GetCustomAnnotations. Let me check the git history to understand the state of this code and whether the standalone RayCluster ever had it.Assistant
So the standalone RayCluster never had
GetCustomAnnotationsorGetWorkloadNameExtraPartin the git history (on the main branch). The PR #9960 added them to RayJob and RayService, but NOT to standalone RayCluster.But the issue is about v0.16.5 which is the release-0.16 branch. The PR #10160 (mentioned in the issue) added generation-based elastic workload names on release-0.16. That PR might have added
GetCustomAnnotationsto the standalone RayCluster on the release-0.16 branch.Hmm. So the situation is: on the main branch (current HEAD), the standalone RayCluster doesn't implement GetCustomAnnotations, so the bug as described doesn't occur. But the issue describes a real bug on release-0.16.
Wait, but my task is to resolve the issue in THIS repository. The repository is at a specific commit. Let me check what commit this is and whether it's main or release-0.16.
Let me check the current branch and the Kueue version.
Assistant
Let me look at the existing tests for
GetWorkloadslicingRayClusterCustomAnnotationsto understand the expected behavior.Assistant
Let me look at the raycluster_webhook.go and understand the full picture of how the standalone RayCluster handles these annotations.
Assistant
Let me look at the RayJob and RayService controllers to understand the full pattern.
Assistant
Let me check the RayService controller's implementation.
Assistant
Let me look at the
mergeAnnotationsfunction in the reconciler to understand the patching behavior.Assistant
Let me look at the e2e test changes from PR #9960 to understand the standalone RayCluster scenario.
Assistant
Let me search for standalone RayCluster elastic e2e tests on main to understand the expected behavior.
Assistant
Let me carefully list all methods on the standalone RayCluster type to confirm it doesn't implement these interfaces.
Assistant
Let me check where the
RayClusterPodsetReplicaSizesAnnotationis consumed/read to understand its purpose.Assistant
Let me look at how
GetWorkloadNameExtraPartis used in the reconciler for workload name generation.Assistant
Let me check where
ParsePodSetReplicaSizesandComparePodSetCountsare called (consumers of these annotations).Assistant
Let me search the entire codebase (including tests) for where these functions are consumed.
Assistant
Let me check the testing utility for RayCluster to understand the type used in tests.
Assistant
So
ClusterWrapperembedsrayv1.RayCluster.MakeClusterreturns*ClusterWrapper. The test's RayCluster is a*ClusterWrapper, which embedsrayv1.RayCluster.When the existing test creates the RayCluster for the fake client, it does:
rayCluster := testingrayutil.MakeCluster("test-raycluster", "default").Obj()Let me check what
.Obj()returns.Assistant
I now have a clear understanding. Let me verify my understanding of the current state and reproduce the issue with a test script first. Let me look at the exact current helper code once more.
Assistant
Let me write a reproduction script that demonstrates the bug: a standalone RayCluster jobObject being passed with its own name as rayClusterName, causing the generation annotation to be written back onto itself.
Assistant
Let me set up the Go environment variables.
Assistant
Let me check the ClusterWrapper methods for setting annotations.
Assistant
There's a
SetAnnotationmethod. Let me fix my repro test.Assistant
I've reproduced the bug. The standalone RayCluster writes its own generation ("273390") back as the
raycluster-generationannotation, which causes a self-update loop. Now let me apply the fix toGetWorkloadslicingRayClusterCustomAnnotations.Assistant
Now let me apply the fix:
Assistant
Now let me run my reproduction test to confirm the fix works:
Assistant
The fix works. The standalone RayCluster no longer writes its own generation back. Now let me run the existing tests to make sure I didn't break anything.
Assistant
All existing tests pass. Now let me run the full raycluster package tests plus rayjob and rayservice packages to ensure nothing broke.
Assistant
Let me also run the jobframework tests since the reconciler handles these annotations.
Assistant
Let me search more broadly for where the podset-replica-sizes annotation is consumed, including the workloadslicing package.
Assistant
Let me look at the RayJob controller test that uses these annotations to understand the test expectations.
Assistant
The fix is working and existing tests pass. Let me clean up my reproduction test file and run a broader set of tests to make sure nothing is broken.
Assistant
All tests pass. Let me also run the workloadslicing package tests since the helper depends on it.
Assistant
Let me review the final diff to make sure it's clean.
Assistant
The diff looks clean. Let me run
go veton the affected package to ensure there are noissues.Assistant
Let me verify formatting with gofmt and check for the line length linter (golines) mentioned in the git history.
Assistant
Let me check the line length limit configuration since the repo enforces it.
Assistant
No lines exceed 200 chars. Let me check if golangci-lint is available to run the full lint.
Assistant
golines reports no changes needed. Let me run the full raycluster package test suite once more to confirm everything is green.
Assistant
Let me do a final review of the modified function to confirm correctness.
Assistant
Let me write one more comprehensive temporary test to verify edge cases (standalone with mismatched name, and a RayJob-like object), then remove it.
Assistant
All edge cases pass. Let me remove the temporary test file and confirm the working tree is clean except for the intended change.
Assistant
Let me run the affected test packages one final time to confirm everything is green.
Assistant
The fix is complete and all tests pass. Let me do a final check to ensure no temporary files are left behind and verify the final diff.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.