← Back to Pull requests

ConfigurablePreemptions: do not skip equivalent workloads in ClusterQueues using a PreemptionConfig #18492

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 08, 2026 08:16 UTC
Author

<!-- Thank you for contributing! Check CONTRIBUTING.md for details. -->

What type of PR is this?

/kind bug

What this PR does / why we need it?

With SchedulingEquivalenceHashing (on by default), when the head of a BestEffortFIFO ClusterQueue is requeued as NoFit or PreemptionNoCandidates, every pending workload with the same scheduling hash is moved to inadmissible with it, and new workloads with that hash go straight there.

The hash covers the PodSet shape and the effective priority. A PreemptionConfig also selects by properties of the preemptor the hash leaves out: labels (preemptorSelector, numeric label comparisons), priority class (preemptorPriorityClassSelector), base priority and LocalQueue (WithinLocalQueue scope). In the issue's setup, the team-b head that preemptorSelector excludes gets PreemptionNoCandidates and takes the team-a workloads with it, although the rule would let them preempt. They sit in inadmissible with no QuotaReserved condition until something unrelated requeues the ClusterQueue.

Changes:

  • For a ClusterQueue that references a PreemptionConfig (with ConfigurablePreemptions enabled), the scheduling hash of its workloads also covers the preemptor fields the rules read (workload.PreemptorHashFields, listed by config.PreemptorHashFields): the values of the label keys in preemptorSelector and in numericLabels that compare against the preemptor, spec.priorityClassRef if a rule has preemptorPriorityClassSelector, the base priority if a candidate selector compares Base priority, and the LocalQueue if a selector uses WithinLocalQueue. computeSchedulingHash digests them with the rest of the shape, so there is still one hash. A field a rule reads but the workload lacks is hashed as missing. Labels no rule reads, such as the job UID, are left out, so equivalence classes still form. If the rules read nothing from the preemptor, the hash is the plain scheduling hash.

  • The ClusterQueue keeps the fields of its PreemptionConfig and sets them on the workloads it queues; when they change, it recomputes the hashes of its queued workloads (inflight ones on requeue).

  • The queue manager reads the PreemptionConfig once per reference: on the first NoFit / PreemptionNoCandidates requeue after the ClusterQueue starts referencing it, before the manager takes its lock. Its client is the cached one the scheduler already reads the object with on every preemption attempt, so once that informer is running this adds no API call, and there is no explicit watch. Until the fields are read, the ClusterQueue doesn't bulk-move; a failed read is retried on the next such requeue.

  • A bulk-moved workload whose read fields change (for example a relabel) leaves inadmissible.

  • A workload whose read fields change while the scheduler evaluates it is retried on a NoFit / PreemptionNoCandidates requeue, instead of bulk-moving the workloads that share its new hash.

  • When the referenced PreemptionConfig changes (starts, switches, or is dropped), the ClusterQueue requeues its inadmissible workloads.
  • Without a PreemptionConfig, or with ConfigurablePreemptions disabled, the behavior is unchanged.

    Fixes #18487

    Useful notes for your reviewer

    The fields are read once per PreemptionConfig reference, so an edit of the rules isn't picked up by this PR: refreshing the fields and requeueing inadmissible workloads on a PreemptionConfig change is the follow-up tracked in #18726. Main doesn't requeue on a PreemptionConfig edit either.

    The list of preemptor fields lives in config.PreemptorHashFields (pkg/scheduler/preemption/config/preemptor_hash_fields.go) and mirrors what matchesPreemptor and filters.NewCandidateFilters read from the preemptor; both point to it, as a new preemptor-dependent selector or filter has to be added there too.

    | Behavior | Level | Command and result | Not run and why |
    |---|---|---|---|
    | A preemptor allowed by preemptorSelector is admitted while an excluded same-shape head stays pending | integration | ginkgo --race ./test/integration/singlecluster/scheduler/configurablepreemptions/: passed | |
    | Existing equivalence-hashing behavior is unchanged | integration | ginkgo --race ./test/integration/singlecluster/scheduler/inadmissible/: passed; go test ./test/integration/singlecluster/scheduler/: passed | |
    | Which preemptor fields a config reads | unit | go test -race ./pkg/scheduler/preemption/config/ -run TestPreemptorHashFields: pass | |
    | The scheduling hash tells apart workloads differing in a read field and keeps together ones differing only elsewhere (missing vs empty label, priority class, base priority, LocalQueue); Update keeps the fields | unit | go test -race ./pkg/workload/ -run 'TestSchedulingHashPreemptorHashFields\|TestSetPreemptorHashFields': pass | |
    | The ClusterQueue recomputes the hashes of its active and inadmissible workloads when its fields are read or dropped | unit | go test -race ./pkg/cache/queue/ -run TestSetPreemptorHashFieldsRehashesQueuedWorkloads: pass; fails when the queued workloads aren't recomputed | |
    | The requeue reads the PreemptionConfig: bulk move, later pushes and relabels follow the extended key; no bulk move before it has been read; unchanged with the gate off | unit | go test -race ./pkg/cache/queue/ -run TestRequeueWorkloadReadsPreemptionConfig: pass; fails without the extended key, without the relabel check, or when bulk-moving before the rules are read | |
    | The requeue reads the PreemptionConfig without the queue manager lock held, and only once per reference | unit | go test -race ./pkg/cache/queue/ -run 'TestRequeueWorkloadReadsPreemptionConfigWithoutLock\|TestRequeueWorkloadReadsPreemptionConfigOncePerReference': pass; fail when the read happens under the lock, or on every requeue | |
    | A workload relabeled in a read field while inflight is retried without a bulk move; a change of an unread field keeps the bulk move | unit | go test -race ./pkg/cache/queue/ -run TestRequeueWorkloadWithPreemptorHashFieldsChangedWhileInflight: pass; fails without the retry | |
    | A change of the referenced PreemptionConfig requeues inadmissible workloads; no bulk move before the rules are read | unit | go test -race ./pkg/cache/queue/ -run 'TestUpdateClusterQueuePreemptionConfig\|TestUpdateWithPreemptionConfigStopsBulkMoves\|TestRequeueHashTriggerByReason': pass | |
    | Queue, cache, scheduler and workload packages | unit | go test -race ./pkg/scheduler/... ./pkg/cache/... ./pkg/workload/...: pass | |
    | Lint and formatting | lint | make fmt-verify ci-lint: pass | full make verify |

    Gate: ConfigurablePreemptions
    Default: false
    PreRelease: Alpha
    Version: 0.20
    Off-path test: TestRequeueWorkloadReadsPreemptionConfig/"the PreemptionConfig is ignored with ConfigurablePreemptions disabled", TestUpdateClusterQueuePreemptionConfig/"the PreemptionConfig is ignored with ConfigurablePreemptions disabled"

    Release note

    ``release-note
    ConfigurablePreemptions: Fixed a bug where, with SchedulingEquivalenceHashing enabled, a pending Workload that no PreemptionConfig rule applies to could block same-shape Workloads that the rules allow to preempt in a BestEffortFIFO ClusterQueue.

    
    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->
    
    ## AI summary
    
    This PR changes how Kueue groups equivalent pending workloads for bulk moves to inadmissible. It applies to ClusterQueues that reference a `PreemptionConfig` when the `ConfigurablePreemptions` feature gate is enabled. Without a referenced config, or with the gate disabled, behavior is unchanged.
    
    - The scheduling equivalence hash includes the preemptor fields that the config rules read. These fields are selected label keys, priority class, base priority, and LocalQueue. A field that a rule reads but a workload lacks is hashed as missing. Fields that the rules do not read stay out of the hash.
    - `config.PreemptorHashFields` lists the fields that the rules read. Code that adds a selector or filter that reads a new preemptor field must update this list.
    - The queue manager reads the referenced config on the first `NoFit` or `PreemptionNoCandidates` requeue, before it takes its lock. It skips the bulk move until the fields are read. If a read fails, the manager retries on a later such requeue.
    - Inadmissible workloads are requeued when the `PreemptionConfig` reference changes. A change to a field that a bulk-moved workload reads removes that workload from the inadmissible list.
    - Editing rules alone does not requeue inadmissible workloads. The author tracks this follow-up in issue `#18726`.
    - The PR does not change the flavor assigner. The linked issue (`#18487`) suggests evaluating the rules there. This PR uses a hash-based remedy instead.
    - The integration test in `test/integration/singlecluster/scheduler/configurablepreemptions/cases_test.go` covers the scenario from `#18487`. It checks that an excluded pending workload does not block an allowed workload with the same priority.
    - The diff changes 17 files, with 1382 lines added and 46 removed.
    - The author reports passing checks for the configurable-preemption and inadmissible integration suites. The author also reports passing unit tests, `go test -race` on the scheduler, cache, and workload packages, and `make fmt-verify ci-lint`. Full `make verify` was not run. These results were not re-run for this summary.
    
    ## Suggested release note
    
    
    text
    Scheduling: Fixed a bug that caused a pending workload whose PreemptionConfig rules select no preemption targets to block later equal-priority workloads that the rules allow to preempt. Now Kueue evaluates those later workloads, because workloads whose rule-relevant preemptor fields differ are no longer moved to inadmissible together. This behavior is gated by the ConfigurablePreemptions feature gate.
    ``
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mansur-akhmadi Review duration: 33230m
    All Vouch review confidence checks passed
    Residual risk 0.42 = Change Risk (0.75) × (1 − Review Confidence (0.44)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.75 · 650 lines diff across 8 files
    0.75
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.075
    Real PR Conversation Timeline
    1 comments
    "Review active on #18492"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 44.2% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 75.2% (HIGH) · Higher = larger blast radius
    75.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.2% · Lower = rushed or shallow review
    44.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 42.0% · Moderate risk
    42.0%