ConfigurablePreemptions: do not skip equivalent workloads in ClusterQueues using a PreemptionConfig #18492
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
mansur-akhmadi
<!-- 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 aBestEffortFIFOClusterQueue is requeued asNoFitorPreemptionNoCandidates, 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
PreemptionConfigalso selects by properties of the preemptor the hash leaves out: labels (preemptorSelector, numeric label comparisons), priority class (preemptorPriorityClassSelector), base priority and LocalQueue (WithinLocalQueuescope). In the issue's setup, the team-b head thatpreemptorSelectorexcludes getsPreemptionNoCandidatesand takes the team-a workloads with it, although the rule would let them preempt. They sit in inadmissible with noQuotaReservedcondition until something unrelated requeues the ClusterQueue.Changes:
PreemptionConfig(withConfigurablePreemptionsenabled), the scheduling hash of its workloads also covers the preemptor fields the rules read (workload.PreemptorHashFields, listed byconfig.PreemptorHashFields): the values of the label keys inpreemptorSelectorand innumericLabelsthat compare against the preemptor,spec.priorityClassRefif a rule haspreemptorPriorityClassSelector, the base priority if a candidate selector comparesBasepriority, and the LocalQueue if a selector usesWithinLocalQueue.computeSchedulingHashdigests 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.PreemptionConfigand sets them on the workloads it queues; when they change, it recomputes the hashes of its queued workloads (inflight ones on requeue).PreemptionConfigonce per reference: on the firstNoFit/PreemptionNoCandidatesrequeue 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.NoFit/PreemptionNoCandidatesrequeue, instead of bulk-moving the workloads that share its new hash.PreemptionConfigchanges (starts, switches, or is dropped), the ClusterQueue requeues its inadmissible workloads.Without a
PreemptionConfig, or withConfigurablePreemptionsdisabled, the behavior is unchanged.Fixes #18487
Useful notes for your reviewer
The fields are read once per
PreemptionConfigreference, so an edit of the rules isn't picked up by this PR: refreshing the fields and requeueing inadmissible workloads on aPreemptionConfigchange is the follow-up tracked in #18726. Main doesn't requeue on aPreemptionConfigedit either.The list of preemptor fields lives in
config.PreemptorHashFields(pkg/scheduler/preemption/config/preemptor_hash_fields.go) and mirrors whatmatchesPreemptorandfilters.NewCandidateFiltersread 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
preemptorSelectoris 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);
Updatekeeps 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
PreemptionConfigwithout 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
PreemptionConfigrequeues 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 | fullmake 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.
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 -->