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 locate the Ray integration and annotation helper, inspect nearby tests and call sites, then reproduce the behavior through the smallest relevant unit test path before implementing a narrowly scoped fix. Afterward I’ll run the affected test packages and review the diff.
- Assistant
rgis unavailable in this environment, so I’ll use recursivegrepto find the same symbols and first confirm the working tree state. - Assistant
The shared helper has three callers, but the initial search only showed explicit RayJob/RayService methods. I’ll inspect the RayCluster controller and helper implementation plus its existing table tests to understand how standalone clusters satisfy the interface and where identity should be detected safely (name alone versus namespace/type).
- Assistant
The helper always fetches and emits generation whenever workload slicing is enabled, including when the supplied object is itself that RayCluster. I’ll inspect the standalone adapter construction and the full test table setup to choose an identity check that cannot accidentally suppress generation for a RayJob/RayService sharing a name.
- Assistant
The standalone type’s custom-annotation method is likely defined in
common.govia a receiver not caught by the earlier pattern. I’ll enumerate receiver methods and inspect relevant imports and generation/name logic, including how elastic workload naming consumes the annotation. - Assistant
In this checkout, standalone
RayClustercurrently does not implementJobWithCustomAnnotations, contrary to the reported release behavior, while RayJob and RayService do. This may reflect an incomplete forward-port or branch divergence. I’ll inspect history and feature-related tests to determine the intended current architecture before changing the helper API or adding a method. - Assistant
The generation feature entered in commit
80b04a2c8. I’ll inspect that patch and its parent/current differences; this should reveal whether standalone support was intentionally excluded on main and whether the bug fix belongs in the shared helper as the issue suggests. - Assistant
The intended fix can be localized in the shared helper: when
jobObjectis a typed*rayv1.RayClusterwhose name equalsrayClusterName, serialize replica sizes but neither fetch the object nor emit its generation. A type-and-name check preserves behavior for RayJob/RayService even if either happens to share the cluster’s name. Before editing, I’ll create an external temporary reproducer (not a repository test) that calls the helper with a standalone typed RayCluster and verifies the current unwanted key. - Assistant
I found the feature-gate API. I’ll run a small
/tmpGo program against the fake client with generation 7; it should currently print both replica-size and self-generation annotations, directly reproducing the faulty helper behavior without modifying repository tests. - Assistant
The reproducer was blocked only because this sandbox has no default Go cache/home. I’ll rerun with cache directories under
/tmp. - Assistant
The reproducer confirms the bug: the helper emits
raycluster-generation:7back onto the same standalone object. I’ll now add the type-and-name guard, while continuing to emitraycluster-podset-replica-sizes; non-standalone callers will retain existing fetch/error/not-found semantics. - Assistant
The guard is in place and the diff is clean. I’ll rerun the exact temporary reproducer; success means the returned map contains only replica sizes and no generation key. Then I’ll exercise the existing helper table to ensure RayJob-like objects still receive generation and preserve not-found/error behavior.
- Assistant
The reproducer now omits the self-generation annotation, and the existing helper test passes, confirming unchanged behavior for non-RayCluster objects. I’ll run all unit tests in the three direct consumer packages (
raycluster,rayjob, andrayservice) to check both standalone logic and top-level-object generation tracking. - Assistant
All affected package tests pass. I’ll now review the complete working-tree diff and status, check formatting/whitespace once more, and inspect whether any generated or unrelated files changed before finalizing.
- Assistant
One important edge case remains: an already-affected standalone cluster may still carry the stale generation annotation. I need to inspect how the reconciler applies returned custom annotations—whether omission leaves an existing key untouched or removes it—because the requested “omit” behavior must also stop loops for upgraded objects that already have the annotation.
- Assistant
Omission likely means no deletion, but I’ll inspect
mergeAnnotationsexactly. If it only merges, an old stale value remains; however, because it is no longer recalculated, it should not cause repeated patches. Whether migration should remove it is a separate compatibility question constrained by the issue’s explicit request to omit the key.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.