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 find all the places where
GetWorkloadslicingRayClusterCustomAnnotationsis called.Assistant
Let me check the RayCluster controller.
Assistant
Now let me look at the reconciler to understand how
GetCustomAnnotationsis called and how the metadata gets updated.Assistant
Let me see the interface definition.
Assistant
Let me see if RayCluster has its own GetCustomAnnotations method.
Assistant
Let me look for places where RayCluster is being treated as a job with the
GetWorkloadNameExtraPartfunction.Assistant
Let me search for more context to see how RayCluster is being treated as a job with GetCustomAnnotations.
Assistant
Let me look at the raycluster_controller.go and see if there's a GetCustomAnnotations function I might have missed.
Assistant
Let me check git log to find related commits.
Assistant
Let me search for the specific call pattern in the issue description.
Assistant
Let me check if there are similar issues that have been fixed.
Assistant
Let me look at the test file for the
GetWorkloadslicingRayClusterCustomAnnotationsfunction.Assistant
Let me look at the actual issue mentioned in #10160.
Assistant
Let me look at the e2e tests for raycluster.
Assistant
Let me look at the e2e test to see if there are tests for this scenario.
Assistant
Let me look at workloadslicing.
Assistant
Let me check if there's any code in the reconciler that uses GetCustomAnnotations on RayCluster.
Assistant
Let me check if there's a GetCustomAnnotations implementation for the standalone RayCluster.
Assistant
Let me look at the raycluster webhook to see if it's being triggered.
Assistant
Let me look at the workloadslicing in the reconciler.
Assistant
Now I need to understand the issue. The reconciler checks if
job.(JobWithCustomAnnotations)and only then callsGetCustomAnnotations. Since RayCluster does not implement this interface, it should not be called.BUT, perhaps this issue was filed based on a planned implementation where RayCluster would implement
GetCustomAnnotations. Or, the issue is preemptive - asking to add the check insideGetWorkloadslicingRayClusterCustomAnnotationsto be safe.Let me look more carefully at the reconciler to see what
WorkloadSliceEnabledis.Assistant
Let me check the git log for recent PRs that might have added the GetCustomAnnotations for RayCluster.
Assistant
Let me look for any place where
GetCustomAnnotationsmight be called on a RayCluster.Assistant
Let me look at the workload slicing code more carefully.
Assistant
Let me see if the RayCluster is registered as a job that implements
JobWithCustomAnnotations.Assistant
Let me look more carefully at the standalone RayCluster path. Maybe we need to add
GetCustomAnnotationsto the RayCluster.Assistant
Let me search for the entire issue description to find the specific function.
Assistant
Let me look at the recent test for the RayCluster controller.
Assistant
Let me look at the e2e tests to see if there's a test for the standalone RayCluster with workload slicing.
Assistant
Let me look for any other code path that calls the function or its related functions.
Assistant
Now I understand the issue. Let me create a reproduce script to verify the bug.
Assistant
Let me write a temporary test to reproduce the issue.
Assistant
Let me create a more focused reproduction test in the existing test file.
Assistant
Now I understand the issue. Let me implement the fix in
GetWorkloadslicingRayClusterCustomAnnotations.Assistant
Now I'll apply the fix:
Assistant
I see there are formatting issues. Let me view the file to confirm.
Assistant
Let me fix the formatting issue - missing blank line between functions.
Assistant
Let me fix the formatting issue - missing blank line between functions.
Assistant
I see there's an issue with the function structure. Let me check and fix it.
Assistant
Let me verify the file is correct by viewing it with
cat -Ato see exact indentation.Assistant
The file is correct. Let me verify the code compiles and run tests.
Assistant
Now let me write a test to verify the bug is fixed.
Assistant
Let me create a test file inside the package to test the fix.
Assistant
The test passes with my fix. Let me also verify that the bug exists by reverting the fix and running the test again.
Assistant
The test confirms the bug exists in the original code. Now let me restore the fix.
Assistant
The fix works. Now let me clean up the test file and check the existing tests pass.
Assistant
All tests pass. Now let me also check edge cases - what if the standalone RayCluster has a different name from the rayClusterName?
Assistant
Edge cases pass. Now let me clean up the test file.
Assistant
Let me run all the relevant tests to make sure I didn't break anything.
Assistant
All tests pass. Let me view the final state of the fix.
Assistant
The file doesn't end with a newline. Let me fix that.
Assistant
Now the file ends with a newline. Let me run all the tests one more time to confirm everything works.
Assistant
All tests pass. Let me check the final diff.
Assistant
Let me also run a broader set of tests to make sure I didn't break anything.
Assistant
All tests pass. Now let me run the workloadslicing tests too.
Assistant
Let me view the final state of the fix:
Assistant
Let me also clean up any temporary files I created.
Assistant
Now let me also run the linter to check for any code style issues.
Assistant
The code is properly formatted. Let me also look at the test cases more carefully to verify the fix doesn't change behavior for the original test cases.
Assistant
All existing tests pass. Now let me verify the final diff:
Assistant
The fix is complete. Let me submit the changes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.