Skip to content

Fix ResourceFlavor immutability caused by TAS opt-in change#436

Open
salexo wants to merge 3 commits intomainfrom
fix/tas-resourceflavor-immutability
Open

Fix ResourceFlavor immutability caused by TAS opt-in change#436
salexo wants to merge 3 commits intomainfrom
fix/tas-resourceflavor-immutability

Conversation

@salexo
Copy link
Copy Markdown
Collaborator

@salexo salexo commented Mar 24, 2026

Stabilize ResourceFlavor reconciliation for TAS opt-in model

Background

Prior to PR #432, Topology Aware Scheduling (TAS) was active by default for all workloads. Every auto-generated ResourceFlavor referenced a topology, and every pod received a podset-preferred-topology annotation automatically.

PR #432 changed TAS to an opt-in model: workloads must explicitly set preferredTopologyLabel or requiredTopologyLabel to activate topology-aware scheduling. The pod annotation default was correctly removed, but the ResourceFlavor conversion and reconciliation logic needed additional adjustments to fully support this model.

Changes

1. Correct kaiwo/worker label placement (ConvertKaiwoToKueueResourceFlavor)

The kaiwo/worker=true label is now only added to ResourceFlavors that do not have a topologyName set. Flavors with topologyName use kaiwo/nodepool exclusively. This avoids spec drift on topology-enabled flavors, whose specs Kueue treats as immutable.

2. Restore topology reference on auto-generated flavors (CreateDefaultResourceFlavors)

Auto-generated ResourceFlavors retain their topologyName reference to the default topology. This is necessary because Kueue requires the flavor to reference a topology for TAS to function when a workload opts in. The opt-in gate is at the workload level (via annotations), not the flavor level.

3. Handle immutable ResourceFlavor updates (syncResourceFlavors / replaceResourceFlavor)

Added a replaceResourceFlavor helper that:

  • Attempts an in-place update first
  • On Invalid or Forbidden errors (indicating immutability), falls back to delete-and-recreate
  • Handles the case where Kueue's resource-in-use finalizer delays deletion, allowing convergence on subsequent reconciliation cycles
  • Skips action on flavors that are already terminating

4. Sync topologies before flavors (SyncKueueResources)

Reordered resource synchronization so Topology objects are created before ResourceFlavor objects that may reference them.

5. Update documentation

  • Corrected stale comments on PreferredTopologyLabel and DefaultTopologyName that still described the old default-on behavior
  • Regenerated CRD manifests and reference docs
  • Added TAS documentation to the admin configuration guide (topology setup, immutability behavior, two-layer opt-in model)
  • Added TAS section to the scientist scheduling guide (field semantics, examples, prerequisites)

Chainsaw tests

Added test/chainsaw/tests/standard/kaiwoqueueconfigs/tas-opt-in/ with four test cases:

  • auto-generated-flavors-topology-and-labels: Verifies auto-generated flavors have topologyName set and do not carry kaiwo/worker in nodeLabels
  • topology-flavor-labels: Verifies correct label assignment for user-defined flavors with and without topology
  • flavor-spec-update-mutable: Tests normal in-place update of a mutable flavor
  • flavor-topology-migration: Tests the delete-and-recreate path when migrating a flavor from topology-enabled to topology-disabled

@salexo salexo force-pushed the fix/tas-resourceflavor-immutability branch from d728b90 to 31534ce Compare March 24, 2026 13:00
The commit c23eccf moved kaiwo/worker=true outside the if/else in
ConvertKaiwoToKueueResourceFlavor, causing spec drift on existing
ResourceFlavors that had topologyName set. Since Kueue makes
ResourceFlavor specs immutable once topologyName is set, the controller
entered an infinite update-rejection loop. The flavor was also stuck
deleting due to Kueue's resource-in-use finalizer.

Fixes:
- Restore kaiwo/worker label to only apply to flavors without topology,
  preventing spec drift on immutable ResourceFlavors
- Keep topologyName on auto-generated ResourceFlavors (enables TAS
  capability); TAS is opt-in at the workload level via
  preferredTopologyLabel/requiredTopologyLabel annotations
- Add replaceResourceFlavor helper in syncResourceFlavors that attempts
  in-place update, falls back to delete-and-recreate only on
  immutability errors (Invalid/Forbidden), skips terminating objects,
  and accepts eventual convergence across reconciliation cycles
- Reorder SyncKueueResources to sync topologies before resource flavors
- Update stale comments on PreferredTopologyLabel and DefaultTopologyName
- Add chainsaw tests for TAS flavor labels, topology/non-topology flavor
  behavior, mutable flavor updates, and topology migration path
@salexo salexo force-pushed the fix/tas-resourceflavor-immutability branch from 31534ce to ff9a259 Compare March 24, 2026 13:04
williamanzen
williamanzen previously approved these changes Mar 24, 2026
Copy link
Copy Markdown
Contributor

@williamanzen williamanzen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Regenerate CRD manifests and reference docs to reflect the updated Go
comments for defaultTopologyName and preferredTopologyLabel. Add TAS
documentation to the admin configuration guide (topologies, topologyName,
immutability warning, two-layer opt-in model) and the scientist scheduling
guide (field semantics, examples, prerequisites).
williamanzen
williamanzen previously approved these changes Mar 24, 2026
Remove Kueue's resource-in-use finalizer before deleting an immutable
ResourceFlavor during replace. Without this, the finalizer blocks deletion
indefinitely when a ClusterQueue still references the flavor, preventing
the replacement from ever being created.

Also add retry/wait loops in the auto-generated-flavors-topology-and-labels
Chainsaw test to handle timing differences between controller reconciliation
and test assertions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants