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 and finding the relevant code mentioned in the issue.
Assistant
I'll start by exploring the repository structure and finding the relevant code mentioned in the issue.
Assistant
Let me look at the relevant files mentioned in the issue. First, the common.go file which likely contains
GetCustomAnnotations.Assistant
Now I can see the
GetWorkloadslicingRayClusterCustomAnnotationsfunction. Let me look at how it's used in the RayCluster controller and webhook.Assistant
Let me look at the RayCluster controller to find its
GetCustomAnnotations:Assistant
The RayCluster controller doesn't have a
GetCustomAnnotationsmethod directly. Let me search the whole repo for where the RayCluster's GetCustomAnnotations is. Let me look at the full raycluster_controller.go to understand the structure.Assistant
The RayCluster controller doesn't have
GetCustomAnnotations. The issue mentions the webhook. Let me check the raycluster_webhook.go:Assistant
The webhook doesn't have
GetCustomAnnotationseither. The issue mentions that "for standalone RayClusters,GetCustomAnnotationscallsGetWorkloadslicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name)". Let me search more broadly:Assistant
Let me check the git branch and version:
Assistant
Let me look at the interface.go to understand the
JobWithCustomAnnotationsinterface and how it's used:Assistant
Let me look at how
GetCustomAnnotationsis used in the reconciler:Assistant
Let me check the git history for the RayCluster controller to understand if
GetCustomAnnotationswas present:Assistant
Let me look at the commit that added the generation-based elastic workload names:
Assistant
Let me look at the e2e test for kuberay to understand the standalone RayCluster scenario:
Assistant
Let me look at the common_test.go to understand the existing tests for
GetWorkloadslicingRayClusterCustomAnnotations:Assistant
Let me check the release-0.16 branch to understand the v0.16.5 code structure:
Assistant
No tags. So this is a detached HEAD. Let me check the release-0.16 branch's raycluster_controller.go to see if it had GetCustomAnnotations. Let me search the commit history.
Actually, let me look at the commit 80b04a2c8 more carefully to see what it did with the RayCluster controller (standalone).
Assistant
Let me check the git history for the standalone RayCluster's GetCustomAnnotations:
Assistant
Let me check the git refs to see if release-0.16 branch is accessible:
Assistant
Let me verify the standalone RayCluster doesn't implement
JobWithCustomAnnotationsand check the issue's referenced PR. Let me look at the rayjob and rayservice controllers to understand the pattern:Assistant
Let me check the full diff of commit 80b04a2c8 for the raycluster_controller.go and rayjob_controller.go:
Assistant
Empty output — the commit 80b04a2c8 didn't touch raycluster_controller.go. So the standalone RayCluster controller never had GetCustomAnnotations in main.
Let me check the rayjob_controller.go diff for that commit to see if GetCustomAnnotations was added there.
Assistant
Let me check whether the standalone RayCluster implements
ElasticWorkloadNameProviderand look at the workload_names.go:Assistant
Let me check the Kueue version and the workload_names.go to understand the workload name generation:
Assistant
Let me look at the e2e test changes in commit 80b04a2c8 to understand the intended behavior for standalone RayClusters:
Assistant
Let me look at the e2e test for the standalone RayCluster elastic scenario. Let me look at the current kuberay_test.go to understand the elastic RayCluster tests.
Assistant
So the e2e test is about RayJob, not standalone RayCluster. Let me look at the kuberay_test.go more broadly to see if there's a standalone RayCluster elastic test.
Assistant
Let me look at how
mergeAnnotationsworks and how the annotations are applied in the reconciler:Assistant
Let me very carefully search the entire repository for any
GetCustomAnnotationsdefinition related to RayCluster:Assistant
This is the main branch (
v0.0.0-main). Let me check if there are any standalone elastic RayCluster tests and look at how the standalone RayCluster is expected to behave:Assistant
Let me look at the raycluster integration test to see if there's an elastic standalone RayCluster test:
Assistant
Now I have a clear understanding. Let me look at the existing test for the helper to understand the expected format, then examine the
workloadslicing.Enabledfunction:Assistant
Now I understand the full picture. Let me write a reproduction test to confirm the buggy behavior of the shared helper when a standalone RayCluster is passed as the jobObject:
Assistant
Wait, I used
testingrayutilbut the package israycluster(the testing wrapper). Let me check the import path and name.Assistant
The testing package is also named
raycluster. Let me check how common_test.go imports it:Assistant
Let me fix the test to use the correct alias and place it in the package directory temporarily:
Assistant
Need to set GOCACHE/HOME. Let me set them:
Assistant
I've reproduced the buggy behavior: when a standalone RayCluster is passed as the jobObject (name == rayClusterName), the helper returns
raycluster-generation: "0"— the RayCluster's own generation, which causes the self-update loop. Now let me implement the fix inGetWorkloadslicingRayClusterCustomAnnotations:Assistant
Now let me apply the edit using the edit command on the open file. First let me open the file:
Assistant
Now let me apply the edit replacing lines 335-366 with the fixed version:
Assistant
The edit is applied. Now let me run my reproduction test to confirm the fix:
Assistant
The fix works. The standalone RayCluster now gets
raycluster-generation: ""(empty), which won't trigger a loop. Let me run the existing tests to make sure I didn't break anything:Assistant
All existing tests pass. Let me run the RayJob and RayService tests that use this helper:
Assistant
All tests pass. Let me verify formatting and run a broader build/vet:
Assistant
No formatting or vet issues. Let me run the jobframework reconciler tests to ensure the broader behavior is intact:
Assistant
Let me look at the RayJob controller's
TestGetCustomAnnotationsto ensure the RayJob path still sets the generation annotation correctly:Assistant
The RayJob tests pass (jobObject is a
*rayv1.RayJob, so the type assertion to*rayv1.RayClustercorrectly fails, preserving the existing fetch behavior). My fix is consistent with the existing "raycluster not found" convention (which returns"").Now let me clean up the temporary test file and do a final review of my change:
Assistant
Let me review the final diff:
Assistant
The diff looks clean. Let me run the full relevant test suite one final time to confirm everything passes:
Assistant
All tests pass and the build succeeds. Let me do a final check for any tests that might assert generation annotation behavior on standalone RayClusters, and run the raycluster integration test package compile check:
Assistant
No tests reference the generation annotation in the test directory, and the integration tests compile fine.
Let me do a final review of the complete modified function to ensure correctness:
Assistant
The fix looks complete and correct. Let me run one final comprehensive temporary test covering the key edge cases (standalone, RayCluster with different name, RayJob-equivalent), then clean up:
Assistant
Both edge cases pass. The standalone RayCluster omits the generation annotation, and the fetch path still works for RayCluster-type jobObjects with a different name. Now let me clean up the temporary test file:
Assistant
The temporary test file is removed. Only
pkg/controller/jobs/raycluster/common.gois modified. Let me run a final test pass on all affected packages:Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.