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
Now let me look at the raycluster_controller.go to see how
GetCustomAnnotationsis used.Assistant
Let me check the jobframework interface to see how
GetCustomAnnotationsis invoked.Assistant
Let me check the RayCluster controller to see if it has a
GetCustomAnnotationsdefined.Assistant
Now let me check the RayCluster controller to see whether it implements the
GetCustomAnnotationsmethod.Assistant
Let me look for any references to
raycluster-generationannotation in the codebase.Assistant
Let me look at the RayCluster reconciler to understand the flow.
Assistant
Let me look at the RayJob controller to understand the implementation pattern.
Assistant
Let me check the git log to see the recent changes.
Assistant
Let me look at the entire RayCluster controller to see if it implements
GetCustomAnnotations.Assistant
Let me check how
JobWithCustomAnnotationsis used and whether the RayCluster might implement it through some other means.Assistant
Let me check the v0.16.5 release-0.16 branch to see if it has different code.
Assistant
Let me check the version of the project.
Assistant
Let me check the git history more carefully for the RayCluster controller.
Assistant
Let me see the actual change that was made by
Generate elastic workload name based on raycluster generation (#9960).Assistant
Let me check if there is an existing way for RayCluster to call
GetCustomAnnotations.Assistant
Let me see the v0.16 release branch.
Assistant
Let me look at the reconciler to understand the call flow.
Assistant
Let me search more thoroughly for
GetCustomAnnotationsin the RayCluster package.Assistant
Let me see if the release-0.16 branch has the issue.
Assistant
Let me search for the exact version.
Assistant
Let me check more carefully - look at all the changes to the RayCluster controller.
Assistant
Let me check the existing tests for the RayCluster reconciler.
Assistant
Let me check if the RayCluster is supposed to have
GetCustomAnnotationsin main, by looking at related files.Assistant
Let me look at the e2e tests for the standalone RayCluster.
Assistant
Let me check if there's a GetCustomAnnotations in the RayCluster by looking at related files.
Assistant
Let me look at the RayCluster controller history more carefully.
Assistant
Let me check the v0.16.5 changelog.
Assistant
Let me check the commit 80b04a2c8 to see the entire change.
Assistant
Let me check for any newer changes to the RayCluster that may have added
GetCustomAnnotations.Assistant
Let me actually verify by looking at the v0.16.5 code through git.
Assistant
Let me look at the test files for the e2e kuberay tests to understand the standalone RayCluster test.
Assistant
Let me look at the latest test for the standalone RayCluster to understand the expected behavior.
Assistant
Let me check where
GetWorkloadslicingRayClusterCustomAnnotationsis called.Assistant
Let me verify the RayCluster in main branch by looking at the entire file.
Assistant
Let me try downloading the v0.16.5 release to check the code.
Assistant
Let me see the full v0.16.5 RayCluster controller file.
Assistant
Let me look at the integration test to see what's expected for the standalone RayCluster.
Assistant
Let me also look at the v0.16.5 test files for the standalone RayCluster.
Assistant
Let me look at the test for
GetWorkloadslicingRayClusterCustomAnnotations.Assistant
Now let me look at the existing tests to understand the format better.
Assistant
Let me look at the PR that introduced the change.
Assistant
Now I understand the issue. Let me apply the fix to
GetWorkloadslicingRayClusterCustomAnnotationsincommon.go.Assistant
Now let me apply the fix:
Assistant
Let me apply the fix.
Assistant
Now let me verify the change:
Assistant
Now let me build the project to verify the fix compiles:
Assistant
The build passes. Now let me run the existing tests to verify nothing is broken:
Assistant
All tests pass. Now let me write a reproduction test to confirm the fix:
Assistant
Let me fix the script:
Assistant
Let me write a proper test file:
Assistant
I need to refine the fix. The annotation should be omitted (not present in the map at all), not just set to empty. Let me update:
Assistant
Now let me run the test again:
Assistant
The test passes. Now let me run the existing tests:
Assistant
All tests pass. Let me also run the rayjob and rayservice tests:
Assistant
All tests pass. Let me also add a proper test case in the test file to ensure the fix is covered:
Assistant
Now let me also add a test case to the existing test file:
Assistant
Let me look at the structure of the test more carefully so I can add a proper test case:
Assistant
Let me update the test to add a new test case for the standalone RayCluster:
Assistant
Now let me check the test file:
Assistant
Now let me run the tests:
Assistant
Let me check the MakeCluster function:
Assistant
The
ClusterWrapperhas aSetAnnotationmethod but no direct way to set the annotations map. Let me look at the wrapper more carefully.Assistant
Let me fix the test to set the annotations correctly:
Assistant
I need to add the maps import. Let me check the imports:
Assistant
Now let me run the tests:
Assistant
All tests pass. Let me run the full test suite for the raycluster package:
Assistant
All tests pass. Let me also look at the full diff to make sure my changes are correct:
Assistant
Let me run all the related tests to make sure everything still works:
Assistant
All tests pass. Let me also check the other tests that use the function:
Assistant
All tests pass. Now let me also think about whether the standalone RayCluster on main should have
GetCustomAnnotations. Let me check if the RayCluster on main needs theraycluster-podset-replica-sizesannotation:Assistant
Let me look at the integration test to see if there are any tests for the standalone RayCluster:
Assistant
Let me check the e2e test:
Assistant
Let me run the full test suite to ensure everything passes:
Assistant
All tests pass. Let me also see the diff:
Assistant
Let me also check the build works:
Assistant
Let me think about edge cases. The fix has these properties:
- When
jobObjectis a*rayv1.RayClusterand its name matchesrayClusterName, theraycluster-generationannotation is omitted. - When
jobObjectis not a RayCluster (e.g., RayJob, RayService, or ConfigMap), theraycluster-generationannotation is included. - When the RayCluster is not found, the behavior is unchanged (returns empty string for generation, which is included in the map).
Let me verify edge cases:
- When
Assistant
All tests pass. Now let me also consider: should I also think about the scenario where the standalone RayCluster on main branch needs
GetCustomAnnotations? Looking at the issue:A standalone Kueue-managed elastic RayCluster is continuously updated by Kueue.
The user is on v0.16.5 where the RayCluster has
GetCustomAnnotations. On main, it doesn't. So my fix is preventative - if the RayCluster is added back, it won't cause this issue.But wait, I should also consider whether the standalone RayCluster on main needs
GetCustomAnnotationsto support theraycluster-podset-replica-sizesannotation for autoscaling. Let me check.Looking at the v0.16.5 code, the
GetCustomAnnotationsreturns both:RayClusterPodsetReplicaSizesAnnotationRayClusterGenerationAnnotation
Assistant
All tests pass. Let me also verify the final state of the file:
Assistant
Now let me think about whether I should also add a corresponding fix in the e2e test to make sure the standalone RayCluster doesn't have this annotation. Let me check the e2e test more carefully:
Assistant
Let me also check if there are any related issues in the v0.16.5 e2e test:
Assistant
Let me also check the actual v0.16.5 e2e test for the standalone RayCluster:
Assistant
Let me also look at the diff of the full file to make sure everything is correct:
Assistant
The diff looks good. Let me also run the full test suite one more time to make sure nothing is broken:
Assistant
All tests pass. Let me also clean up the temp files:
Assistant
Let me also re-examine the test file to make sure the test logic is correct:
Assistant
The test looks good. Let me now also think about whether I should also remove
GetCustomAnnotationsfrom the RayCluster on v0.16.5. Let me look at the v0.16.5 code again:Assistant
Let me also look at the e2e tests to make sure my fix doesn't break anything:
Assistant
Now let me also think about whether my fix should be more defensive. Let me check the case where the standalone RayCluster has a different name than expected:
Assistant
Let me clean up the edge test file:
Assistant
Now let me also check that the fix doesn't introduce any other issues. Let me look at the final diff once more:
Assistant
Let me also run the full test suite one more time:
Assistant
All tests pass. Let me also verify that there are no other related tests in the codebase:
Assistant
The
RayClusterPodsetReplicaSizesAnnotationis used in:test/e2e/singlecluster/extended/kuberay_test.go: For RayJob.pkg/controller/jobs/rayjob/rayjob_controller_test.go: For RayJob.pkg/controller/jobs/raycluster/common.go: Definition and use in the function.pkg/controller/jobs/raycluster/common_test.go: For tests.
All these are for RayJob or the function itself, not for the standalone RayCluster. So my fix is correct.
Let me also check the
RayClusterGenerationAnnotation:Assistant
Let me run the full test suite once more to make sure everything passes:
Assistant
All tests pass. Let me also look at the final state of the diff:
Assistant
Let me also run all the tests in the repository to ensure nothing is broken:
Assistant
The e2e and integration tests for
kueue-populatorare failing because they need a Kubernetes cluster to run. These are not related to my changes. Let me skip them and run only the unit tests:Assistant
All unit tests pass. Let me also see the final diff:
Assistant
Now let me also go through the checklist from the issue description:
Checklist
1. If an error was reported in the issue description, I have successfully reproduced it.
- I verified that on v0.16.5, the standalone RayCluster has
GetCustomAnnotationsdefined that callsGetWorkloadslicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name), which would cause the self-reference issue.
- I verified that on v0.16.5, the standalone RayCluster has
Assistant
All tests pass. The fix is complete. Let me summarize what I did:
Summary of the Fix
Issue: 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, creating a self-triggered loop.Root Cause: When
GetCustomAnnotationsis called on a standalone RayCluster, it callsGetWorkloadslicingRayClusterCustomAnnotations(ctx, c, j.Object(), podSets, j.Name). This helper fetches the same RayCluster and returns its generation as an annotation to write back onto the RayCluster. The metadata patch then advances the RayCluster generation, making the annotation stale again.Fix: In
pkg/controller/jobs/raycluster/common.go, modifiedGetWorkloadslicingRayClusterCustomAnnotationsto:- Detect when the
jobObjectis a with the same name as (i.e., a standalone RayCluster).
- Detect when the
Assistant
The fix is in place. 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.