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
Now let me look at the RayCluster controller's
GetCustomAnnotations:Assistant
Let me look at the RayCluster controller and how it's wired up:
Assistant
Let me look at how custom annotations are used in the reconciler:
Assistant
Let me look at the RayCluster controller's full job interface implementation:
Assistant
Interesting - the RayCluster doesn't have a GetCustomAnnotations method. Let me check the webhook for the RayCluster to see where the generation annotation is being set.
Wait, the issue says: "For standalone RayClusters,
GetCustomAnnotationscallsGetWorkloadslicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name)."But the RayCluster controller doesn't implement GetCustomAnnotations. Let me search more broadly.
Assistant
The RayCluster controller itself doesn't implement
GetCustomAnnotations. Let me check the git branch and version to understand the codebase state:Assistant
Let me look at the RayCluster webhook and how the generation annotation is used:
Assistant
Let me check the release-0.16 branch to understand the original code structure:
Assistant
No branches or tags. Let me check whether the current main branch is affected. Let me re-read the issue carefully.
The issue describes:
- The standalone RayCluster's
GetCustomAnnotationscallsGetWorkloadslicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name).
But in the current main branch, the RayCluster doesn't implement
GetCustomAnnotations. Let me check if maybe it was recently added or is expected to be added.Actually, wait. Let me re-read. The issue mentions "This may be related to #10160, which added generation-based elastic workload names on the release-0.16 branch."
The current HEAD is at a newer commit. Let me check whether the RayCluster controller implements GetCustomAnnotations in this codebase. From my grep, it doesn't.
Hmm, but maybe I should look at whether the RayCluster uses the workload slicing path and whether there's a different place where the generation annotation gets written for standalone RayClusters.
Let me look at the workloadslicing package and the RayCluster reconciler to see how a standalone elastic RayCluster gets the generation annotation.
Actually, wait. Let me reconsider. Maybe the current main branch DOES have a RayCluster GetCustomAnnotations that I'm missing. Let me search the entire repository again more carefully.
- The standalone RayCluster's
Assistant
Let me look at the git history of the relevant files:
Assistant
Now I understand the structure. In the current main branch, the RayCluster controller doesn't implement
GetCustomAnnotations. But the issue is from the v0.16.5 release. Let me check whether the current main branch's RayCluster controller implementsGetCustomAnnotations. The issue mentions that standalone RayCluster'sGetCustomAnnotationscallsGetWorkloadslicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name).Let me check the git history to see if RayCluster's GetCustomAnnotations was recently removed or never existed.
Assistant
The RayCluster controller has never had a
GetCustomAnnotationsmethod in the current main branch. But the issue is about the release-0.16 branch. Let me understand the current state of the code and the fix needed. Let me look at the test file for the function:Assistant
Now let me look at the
mergeAnnotationsfunction to understand how the annotations are applied:Assistant
Let me look at the workloadslicing package to understand the standalone RayCluster flow in the main branch:
Assistant
Let me check if the RayCluster controller implements
GetWorkloadNameExtraPartin the main branch. If a standalone RayCluster uses the generation annotation for its workload name, it could also cause issues.Assistant
Let me verify by viewing the full RayCluster controller file:
Assistant
Let me check the workloadslicing package to understand the standalone RayCluster path:
Assistant
Let me verify the current state of the RayCluster controller once more with a comprehensive search:
Assistant
OK so in the main branch, the RayCluster controller does NOT implement
GetCustomAnnotationsorGetWorkloadNameExtraPart.Let me look at the interface.go to understand the interfaces better.
Assistant
Let me check the version of this codebase to determine which branch we're on:
Assistant
Let me check the helm chart version to determine the release version.
Assistant
This is the main branch (0.17.x). Now let me understand how standalone elastic RayClusters are handled in the main branch. Let me look at the e2e tests:
Assistant
Let me look at the e2e test to understand how standalone elastic RayClusters are tested in the main branch.
Assistant
Let me look at the e2e test around line 442 which mentions workload slices:
Assistant
Let me look at how
EnsureWorkloadSlicesand the workload slicing path uses these annotations:Assistant
Let me view the rest of the RayCluster controller to be 100% sure about its interface implementations:
Assistant
Now I have a clear understanding. Let me look at the full
common.goto understand the imports and structure:Assistant
Let me check the testing utilities for RayCluster to write a reproduction test:
Assistant
Now let me write a reproduction test to confirm the issue. I'll create a temporary test that simulates the standalone RayCluster case:
Assistant
Let me fix the test setup by following the existing test pattern:
Assistant
The method is
SetAnnotation, notAnnotation. Let me fix the test:Assistant
The sed didn't work because the line has the annotation with a
.continuation. Let me just rewrite the test file.Assistant
I've reproduced the issue. The standalone RayCluster writes its own generation ("5") back onto itself. Now let me apply the fix to
GetWorkloadslicingRayClusterCustomAnnotations:Assistant
Now let me apply the fix:
Assistant
Now let me run my reproduction test to confirm the fix:
Assistant
The fix works. The standalone RayCluster no longer gets the
raycluster-generationannotation written onto itself. Now let me run the existing tests to make sure nothing is broken:Assistant
All existing tests pass. Now let me run the full raycluster test suite plus the rayjob and rayservice tests that use this function:
Assistant
All tests pass. Now let me also verify that the RayJob and RayService controllers still work correctly with my fix - let me check the RayJob test that tests GetCustomAnnotations:
Assistant
The RayJob tests pass. Let me look at the RayJob test to confirm the generation annotation is still set for the RayJob case (top-level object):
Assistant
Let me verify the RayService test for GetCustomAnnotations and run a broader test to ensure nothing is broken:
Assistant
Let me run a broader test to make sure the build and tests pass:
Assistant
All tests pass. Now let me verify the edge case where a RayCluster is passed as jobObject but with a different rayClusterName (should still fetch the generation). Let me update my reproduction test to also cover this edge case and the RayJob case:
Assistant
Both edge cases pass. Now let me clean up my temporary reproduction test file since I should not add new tests to the repository:
Assistant
Now let me verify the existing tests still pass after removing the repro file, and review my final changes:
Assistant
All tests pass. Let me review my final changes with git diff:
Assistant
The diff looks clean. Let me run the formatter to ensure code style compliance (the repo uses golines):
Assistant
Let me run the linter to ensure code quality:
Assistant
Let me run
go vetto check for any issues:Assistant
Let me run the full test suite for the affected packages one final time to confirm everything passes:
Assistant
All tests pass. Let me also verify the final state of my changes once more:
Assistant
The fix is complete and correct. Let me do a final check of the git status to confirm only the intended file is modified and no test files remain:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.