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
Assistant
Let me explore the relevant code for the RayCluster integration
Assistant
Now let me look at the common.go file for the GetCustomAnnotations function
Assistant
Now let me search for
GetCustomAnnotationsin the codebase to understand how it is usedAssistant
Let me look at the reconciler and understand how annotations are applied
Assistant
me look at how RayJob and RayService use GetCustomAnnotations
Assistant
Let me search if there's a GetCustomAnnotations defined directly on the RayCluster type
Assistant
So GetCustomAnnotations isn't defined for RayCluster directly. Let me check how this is supposed to work
Assistant
Let me look at the git log for context
Assistant
Let me see the changes to the common.go file in that PR
Assistant
Let me look at the reconciler more carefully
Assistant
Let me check if RayCluster implements JobWithCustomAnnotations
Assistant
me search for how this is connected
Assistant
Interesting. So in the current code, RayCluster does NOT have GetCustomAnnotations. Let me search in the latest code or PRs more carefully.
Wait - looking back at the issue description, the user says
GetCustomAnnotationscallsGetWorkloadslicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name). Let me look for this more carefully. Maybe the RayCluster type does implement it in the latest main. Let me check git status and branchesAssistant
Let me look at the raycluster_controller.go file more carefully for the GetCustomAnnotations method
Assistant
Let me look for any open PRs about this issue or commits between 0.16.5 and HEAD
Assistant
me look at the release-0.16 branch
Assistant
Let me check the file size and contents related to the issue.
The issue says the user is running v0.16.5. Let me check the current state of the codebase and check what's happening with
GetCustomAnnotationsfor RayCluster.Wait - the current HEAD doesn't have GetCustomAnnotations on RayCluster. So that means the fix would need to either:
- Add GetCustomAnnotations to RayCluster but handle the standalone case
- Make the fix at the GetWorkloadslicingRayClusterCustomAnnotations function level
- Or some other approach
But the user says "For standalone RayClusters, GetCustomAnnotations calls GetWorkloadslicingRayClusterCustomAnnotations". So that means there's a GetCustomAnnotations somewhere.
Let me check if there are uncommitted files or other branches
Assistant
me check the commit dates
Assistant
Let me look at the v0.16.5 version (or close to it) to see what's there
Assistant
Let me check the version of the file
Assistant
Let me check the v0.16.5 version of the codebase to find out what GetCustomAnnotations the user is referring to.
Assistant
Let me see the rest of the v0.16.5 version file
Assistant
me look at the v0.16.5 common.go file
Assistant
check the v0.16.5 test file for
GetWorkloadslicingRayClusterCustomAnnotationsAssistant
Let me look at the latest master branch to check for GetCustomAnnotations on RayCluster
Assistant
me look for any GetCustomAnnotations on RayCluster more carefully
Assistant
search for where the annotation is being set
Assistant
look at recent changes
Assistant
Let me look at the workloadslicing package
Assistant
Let me look at how GetWorkloadNameExtraPart is used in the workload name generation
Assistant
Let me look at the integration setup and other places to understand how RayCluster is set up
Assistant
look at the kuberay_test.go file
Assistant
Let me search for where the raycluster-generation annotation is set elsewhere
Assistant
Let me look at the webhook more carefully to see if it sets annotations
Assistant
me look at the PR #10160 mentioned in the issue
Assistant
Let me look at the integration tests for RayCluster
Assistant
Let me search for related tests
Assistant
Now I understand the issue. Let me look at the
GetWorkloadslicingRayClusterCustomAnnotationsfunction once more to understand the fixAssistant
Now I have a clear understanding of the issue. The fix is in
GetWorkloadslicingRayClusterCustomAnnotations. Let me also look at the helper function to make sure I understand the comparison correctlyAssistant
Now let me look at the broader code base to understand the test setup
Assistant
Let me check if RayCluster had GetCustomAnnotations at some point
Assistant
Let me check the integration tests to see if there are existing tests for this scenario
Assistant
let me also look at the structure to understand the fix
Assistant
Now I have a clear understanding. Let me apply the fix to
GetWorkloadslicingRayClusterCustomAnnotations:Assistant
me apply the fix directly using the edit command:
Assistant
Now let me apply the fix:
Assistant
Let me verify the code compiles correctly:
Assistant
let me write a temporary test script to verify the fix:
Assistant
run all related tests to verify nothing is broken:
Assistant
me also run the related test for rayservice and rayjob:
Assistant
Let me run the broader tests to make sure nothing else is broken:
Assistant
me check the workload slicing package tests:
Assistant
Assistant
Let me try again with a proper
Assistant
test passes. The fix works correctly. Let me clean up the temporary test file:
Assistant
Now let me run all the tests again to make sure my fix didn't break anything:
Assistant
Let me check the diff of my changes:
Assistant
Let me verify the test passes one more time and also look at the broader picture
Assistant
Let me look at all the tests to make sure my fix is complete:
Assistant
Let me also run a broader set of tests to ensure nothing else is broken:
Assistant
All tests pass. Let me view the final state of the fix:
Assistant
me look at the callers to ensure they don't break:
Assistant
me check the integration tests as well:
Assistant
me also look at the broader tests to ensure nothing else is affected:
Assistant
Let me verify there are no leftover temporary files:
Assistant
Let me verify the final diff:
Assistant
The diff looks clean and well-documented. The fix:
- Detection: Uses a type assertion to check if
jobObjectis a*rayv1.RayClusterwith the same name and namespace as therayClusterName. - Skipping: When the standalone case is detected, the function skips the lookup of the RayCluster's generation and skips setting the
RayClusterGenerationAnnotation. - Preservation: For non-standalone cases (RayJob, RayService, etc.), the original behavior is preserved - the function looks up the RayCluster and sets the generation annotation.
Let me also check the git status:
- Detection: Uses a type assertion to check if
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.