testing: check that topology domain is reserved for preemptor workloads accross cycles - #14687
Conversation
…opology during preemptor eviction cycles
|
@Nilsachy: The label(s) DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
✅ Deploy Preview for kubernetes-sigs-kueue canceled.
|
|
Hi @Nilsachy. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe integration test updates cohort preemption topology and quotas. It uses two 4-CPU preemptor pods to test fragmented capacity. It verifies pending workload conditions after each eviction and confirms preemptor admission after both evictions. ChangesCohort preemption
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This PR adds localized integration-test coverage without changing production behavior, and no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
cc @dkaluza |
I believe this is not fully accurate/correct. What if other workloads starts to preempt workloads in domains that are lexicographicaly first and also would satisfy the first preemptor needs? Wouldn't they replace the "reserved" ones? |
|
/ok-to-test |
IIUC in that case whichever pending preemptor is popped first from the iterator will get the domain. So yes in theory, if another preemptor is popped first, it could steal the domain. But in the classical case, all the preemptor workloads at the head of the queue are ordered by Nominal vs Borrowing -> Priority -> Timestamp so the order shouldn't change across cycles. So I only see such scenario possible with fair sharing. But this IMO is the intended behaviour. If we truly reserve a specific topology domain for a workload regardless of whether it is at the head of the queue, we run the risk of blocking the resources indefinitely (let's say the preemptor workload that reserved this domain never gets admitted because of other higher priority workloads). In that case the nodes are completely idle and unusable no? |
No, let's imagine we have 2 workloads W1 and W2, that need to preempt to be admitted. Then next cycle comes, and W1 as it first in the ordering (as it started preemptions first I guess this is the case) gets assigned to A & B since they are lexicographically first. W2 is assigned to remaining C & D. I'm not saying this is a blocker in general, and that this is bad and we have to fix it - we should just consider if this is problematic for us. I believe it may lead to prolonged waiting for preemption in some circumstances. I think this is not depending on the Fair Sharing in any way.
I don't know actually. Aren't we prioritizing the preemptor anyway? Doesn't it have the quota already locked as for the change in the previous PR? So it will still be before the higher priority workloads that do not have quota reserved yet IIUC. I'm not stating that anything is wrong in the implementation, just pointing out that this is more tricky and we should consider edge cases as described above - cause IIUC current implementation the assigned domains can still change between cycles. |
Oh sorry I didn't understand what you meant. Yes you're right this could happen I think. But is that a problem? Both workloads need the same topology domain so as long as both workloads get admitted do we care about this at all?
IIUC the delay you're mentioning is the eviction duration for C & D? I can't think of a solution where enforcing reservation of A & B for W1 doesn't raising other kinds of problems..
It's correct that we are prioritizing the preemptor but there can be several other preemptor workloads at the same time. I'm thinking of a scenario where those preemptors continuously evaluate before W1 in the iterator. In that case we are not locking the quota either because quota locking happens "per cycle". IMO we should let those other preemptor workloads "steal" both the quota + topology as Kueue specifically wants them to be admitted first. |
The delay I had in mind is the delay of preemting the workloads. W1 started preempting first C & D.
Here I agree if the order says workload should be first to lock the resources we should respect the order. |
Sorry yes I mixed up A & B and C & D but that's what I understood.
Right I see your point. I can't think of an easy fix for that though. One idea that comes to mind is before falling back to But that's probably an overkill for now.. Especially that this is the existing mechanism on |
Actually, if W1 hops onto A & B (the targets of W2), I think there is no guarantee that W2 will be admissible on C & D. For example W1 requires co-location within a block, W2 within a rack. If C & D are in different racks then they were preempted for nothing, causing a disruption. @coderabbitai Please open a GitHub issue that summarizes the above discussion and contains the relevant links. The goal of the issue is to evaluate the problem highlighted by @dkaluza and its impact, not strictly implement a fix yet. Do not assign anyone to the issue. Add area/tas, area/feature. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
repo="kubernetes-sigs/kueue"
pr_number="14687"
echo "Matching discussion comments:"
gh api "repos/${repo}/issues/${pr_number}/comments?per_page=100" \
--paginate \
--jq '.[] | select(.user.login == "kshalot") | select(.body | contains("W2 is assigned to remaining C & D")) | {url: .html_url, body: .body}'
echo
echo "Requested labels:"
gh label list --repo "$repo" --limit 200 \
--json name \
--jq '.[] | select(.name == "area/tas" or .name == "area/feature") | .name'Length of output: 1667 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo="kubernetes-sigs/kueue"
pr_url="https://github.com/kubernetes-sigs/kueue/pull/14687"
requester_comment_url="https://github.com/kubernetes-sigs/kueue/pull/14687#issuecomment-5372450798"
dkaluza_comment_url="$(
gh api "repos/${repo}/issues/14687/comments?per_page=100" --paginate \
--jq '.[] | select(.user.login == "dkaluza") | select(.body | contains("The delay I had in mind is the delay of preemting the workloads")) | .html_url' \
| head -n 1
)"
body_file="$(mktemp)"
trap 'rm -f "$body_file"' EXIT
cat >"$body_file" <<EOF
## Summary
Evaluate topology-domain reassignment across scheduling cycles while preemptions are in progress.
A preemptor can target one set of topology domains in one scheduling cycle, start evictions there, and then select a different set in a later cycle. Another preemptor can cause this change by targeting lexicographically earlier domains that also satisfy the first preemptor.
## Problem to evaluate
The reassignment can extend the time to admission. A workload can wait for evictions in one domain set, then switch to a domain set whose evictions started later. In an edge case, repeated reassignment can make the wait proportional to the eviction duration times the number of relevant workloads.
The reassignment can also make earlier evictions unnecessary. For example:
- W1 requires co-location within a block.
- W2 requires co-location within a rack.
- W1 initially preempts C and D.
- W2 initially preempts A and B.
- In the next cycle, W1 selects A and B because they sort first.
- W2 receives C and D, but C and D can be in different racks.
In this case, W2 may not be admissible on C and D. The evictions for C and D caused disruption without enabling W2 admission.
This issue is for analysis only. It must determine the frequency, impact, and acceptable behavior of this case before proposing a design or implementation change.
## Investigation areas
- Confirm how topology-domain selection, simulated victim removal, quota locking, and scheduling order interact across scheduling cycles.
- Identify workloads with different topology constraints that can make reassigned domains invalid for a waiting preemptor.
- Determine whether reassignment can cause avoidable evictions, delayed admission, starvation-like behavior, or resource underuse.
- Define tests or simulations that reproduce representative cases.
## References
- Pull request: ${pr_url}
- Request to create this issue: ${requester_comment_url}
- Discussion of the delayed-preemption case: ${dkaluza_comment_url:-${pr_url}}
EOF
issue_url="$(
gh issue create \
--repo "$repo" \
--title "Evaluate topology-domain reassignment during ongoing preemptions" \
--body-file "$body_file" \
--label "area/tas"
)"
echo "Created issue: ${issue_url}"Length of output: 3031
The issue has You are interacting with an AI system. |
My question is, why would W1 not target A & B to start with? They are first lexicographically speaking. A & B would have to not exist or be already taken by a higher priority job when W1 issued preemption but somehow became valid candidates for preemption sometime after (but before C & D are fully evicted). Which is looking like less and less likely of an edge case. |
…gmented capacity handling
|
/release-note-none |
dkaluza
left a comment
There was a problem hiding this comment.
The test looks good to me right now - it confirms that basic "ordering properties" are maintained also for the topologies. I think the further improvements in the topology locking that I mentioned are not strictly required right now and we can look into those when some users reports that this is a real issue.
/lgtm
|
LGTM label has been added. DetailsGit tree hash: 7920f44558cd59ae8a0ad74f52b9e44fa49522e6 |
|
/assign @tenzen-y |
tenzen-y
left a comment
There was a problem hiding this comment.
This looks great to me, thanks!
/lgtm
/approve
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dkaluza, Nilsachy, tenzen-y The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/cherrypick release-0.18 |
|
@tenzen-y: once the present PR merges, I will cherry-pick it on top of DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@tenzen-y: new pull request created: #14872 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@tenzen-y: new pull request created: #14873 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@Nilsachy, can you manually open CPs due to #14873 (review) |
Sure I'll do that now |
…is reserved for preemptor workloads accross cycles (#14895) * test: add integration test to verify pending workloads do not steal topology during preemptor eviction cycles * test: update PrioritizePreemptorWorkloads feature gate in TAS integration test * test: update test description to include feature gate condition in tas_test.go * refactor: simplify TAS integration test setup and restructure PrioritizePreemptorWorkloads test case * test: tighten TAS topology error message validation in integration tests * test: update TAS integration test topology and scenario to verify fragmented capacity handling * test: move node x3 definition between integration test cases * test: enable UnadmittedWorkloadsObservability feature gate in TAS integration test * test: remove UnadmittedWorkloadsObservability feature gate and update expectation to WorkloadPending in TAS integration tests * test: add staticcheck suppression for deprecated WorkloadPending reason in TAS integration test
…is reserved for preemptor workloads accross cycles (#14894) * test: add integration test to verify pending workloads do not steal topology during preemptor eviction cycles * test: update PrioritizePreemptorWorkloads feature gate in TAS integration test * test: update test description to include feature gate condition in tas_test.go * refactor: simplify TAS integration test setup and restructure PrioritizePreemptorWorkloads test case * test: tighten TAS topology error message validation in integration tests * test: update TAS integration test topology and scenario to verify fragmented capacity handling * test: move node x3 definition between integration test cases in tas_test.go * test: enable UnadmittedWorkloadsObservability feature gate in tas_test integration tests * test: update WorkloadQuotaReserved reason assertion and remove UnadmittedWorkloadsObservability feature gate in TAS integration test * test: add nolint directive for deprecated WorkloadPending reason in TAS integration test
What type of PR is this?
/kind cleanup
/area testing
What this PR does / why we need it:
This PR adds an integration test to verify that topology domains (nodes/blocks) allocated to a preemptor waiting for multiple evictions cannot be stolen by interim pending workloads across scheduling cycles.
This is a follow-up to #13797. While #13797 ensured that quota is reserved across scheduling cycles when a preemptor is waiting for multiple evictions, it also locked topology assignments:
Deterministic Topology Placement (
compareDomainLevelValues):updateAssignmentForTASsimulates the removal of remaining preemption targets (SimulateWorkloadRemoval(targets)).findTopologyAssignment) sorts candidate domains usingsortedDomains, which falls back tocompareDomainLevelValuesas a deterministic lexicographical tie-breaker (comparing domain hierarchy level values, e.g.,rack-1/node-1vsrack-2/node-2).Preemptor Workload Priority & In-Memory Lock (
cq.AddUsage):preemptorWorkloadat the head of its ClusterQueue (providing stickiness during queue ordering).PrioritizePreemptorWorkloadsenabled,e.IsPreemptorensures the preemptor is sorted first in the scheduling iterator (makeClassicalIterator/fairSharingIterator).cq.AddUsage(usage)inprocessEntry, re-locking its assigned topology domains inTASFlavorSnapshotbefore lower-priority or quota-abundant workloads are evaluated.cq.Fits(FitsCheckNoTAS) and is skipped.This PR adds dedicated integration test coverage in
test/integration/singlecluster/tas/tas_test.goto explicitly test and safeguard this topology locking behavior.Which issue(s) this PR fixes:
Related to #13797
Special notes for your reviewer:
Topology Locking Mechanism:
Even when evictions are staggered across multiple scheduling cycles (e.g., victim 1 terminates in cycle 1, victim 2 terminates in cycle 2), the combination of:
SimulateWorkloadRemovalof remaining targets,compareDomainLevelValues,preemptorWorkload/PrioritizePreemptorWorkloads), andcq.AddUsagetasFlvCache.updateTASUsage),ensures the already freed topology space (e.g. node 1) cannot be stolen by interim workloads while the preemptor is still waiting for remaining victims (e.g. node 2) to drain.
Test Scenario:
wl-a(on node 1) andwl-b(on node 2) occupy the cluster.wl-pendingarrives inclusterQueueC(has enough nominal quota to schedule on a single node).preemptorarrives, requesting full block capacity (2 nodes) and marking bothwl-aandwl-bfor preemption.wl-afinishes eviction.gomega.Consistentlythatwl-pendingis not admitted on the freednode 1in the interim whilewl-bis still draining.wl-bfinishes eviction,preemptoris admitted across both nodes, andwl-pendingremains pending.Does this PR introduce a user-facing change?