Repository navigation
domainmgr: bound the graceful stop wait for default-mode guests - #6453
Merged
eriknordmark merged 2 commits intoSep 7, 2026
Merged
Conversation
This was referenced Sep 1, 2026
Contributor
|
/rerun red |
1 similar comment
Contributor
|
/rerun red |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6453 +/- ##
==========================================
+ Coverage 25.67% 26.01% +0.33%
==========================================
Files 509 519 +10
Lines 93304 95023 +1719
==========================================
+ Hits 23959 24716 +757
- Misses 67496 68273 +777
- Partials 1849 2034 +185 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
milan-zededa
approved these changes
Sep 7, 2026
Contributor
|
@eriknordmark Some merge conflict on this PR to address, otherwise LGTM. |
An application whose configuration leaves the virtualization mode unset gets PV, the zero value of the mode enum. Only xen acts on that mode; under kvm or kubevirt such a guest is an ordinary one that happens to have defaulted, yet deactivating it granted the ACPI poweroff request the entire ten-minute budget before anything else was tried. A guest that cannot service the request yet, one still early in boot for instance, therefore stayed reported as halting for that whole period, holding its memory and any assigned devices, even though the forced stop and the delete that follow would have freed it in seconds. Such a guest now gets the same one-minute wait an HVM or FML guest already gets, after which the stop escalates as before. A xen PV guest keeps the full budget: there the mode names a real paravirtualized guest whose tools are inherent, so a slow but cooperative shutdown is worth waiting out. The decision moves into shutdownBudget, which reports whether a poweroff request is sent at all and how long it is given, so it can be exercised directly. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Deactivating an application in the same second it first reports RUNNING catches a guest which cannot service the ACPI poweroff request yet, so the stop only completes once it escalates. The budget before that escalation depends on the virtualization mode, and an application whose configuration leaves the mode unset gets the zero value, which is the case this covers. The assertion is on how long the application takes to be reported HALTED, because the reported state sequence is the same either way -- only the time spent halting differs. The bound separates two hardcoded budgets an order of magnitude apart rather than an amount of work, so a loaded host moves both ends a little and crosses neither. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
eriknordmark
force-pushed
the
bound-graceful-shutdown
branch
from
September 7, 2026 14:41
9e65bea to
6f1938c
Compare
This was referenced Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #6440.
An application whose configuration leaves the virtualization mode unset gets
PV, the zero value of the mode enum. Only xen acts on that mode; under kvm orkubevirt such a guest is an ordinary one which happens to have defaulted. Yet
deactivating it granted the ACPI poweroff request the entire ten-minute budget
before anything else was tried, because the
PVcase indoInactivatesetsdoShutdownwithout loweringfirstDelayfrommaxDelaythe wayHVMandFMLdo. A guest which cannot service the request yet -- one still early inboot, for instance -- therefore stayed reported as halting for that whole
period, holding its memory and any assigned devices, even though the steps
which follow would have freed it in seconds.
Such a guest now gets the same one-minute wait an
HVMorFMLguest alreadygets, after which the stop escalates exactly as before. A xen
PVguest keepsthe full budget: there the mode names a real paravirtualized guest whose tools
are inherent, so a slow but cooperative shutdown is worth waiting out, and
shortening it would be a behaviour change for those guests that this PR does not
want to make.
The decision moves into
shutdownBudget, which reports whether a poweroffrequest is sent at all and how long it is given, so it can be exercised without
a running domainmgr.
PR dependencies
None. In particular this is independent of #6441 -- see below.
How to test and validate this PR
Covered by a unit test and an evetest test, both validated against un-fixed
code.
TestShutdownBudgetcovers all eight mode/hypervisor combinations. Revertingthe
PVarm toreturn true, maxDelayfails exactly the two rows this PRchanges (
firstDelay = 10m0s, want 1m0s) while the xen,HVM,FML,NOHYPERandLEGACYrows still pass.TestHaltAfterImmediateDeactivate, inevetest/tests/appsand registered inTestAppsSuite, deploys a container application, waits until it is reportedRUNNING and deactivates it immediately -- nothing in between, because anything
which samples state first lets the guest become able to service the request and
the case stops being the one under test. Against an EVE image without this
change it fails:
and passes with it, reporting HALTED 1m37s after the deactivation.
The assertion is on elapsed time because the reported state sequence is
identical either way -- RUNNING, HALTING, HALTED -- and only the time spent
halting differs; there is nothing qualitative to assert on through the EVE API.
The 300s bound separates two hardcoded budgets an order of magnitude apart
rather than an amount of work, so it is not a stopwatch on a loaded host: the
prompt path measured 95-100s across ~90 runs under contention, against 636s and
701s for the two ways of losing the budget.
Measured end to end on EVE-kvm amd64 under evetest, deactivating a container
application in the same second it first reports RUNNING, which is the #6440
trigger. Three EVE images off one common base, differing only in the fix, with
every run's achieved RUNNING->deactivate gap confirmed to be 0s:
Soaked for 8 hours on the middle build: 85 runs, all at a 0s gap, 95-100s,
no outliers, bookended by runs of the un-fixed build which still produced
636s and 637s -- so "never stalled" reflects the change and not a trigger which
quietly stopped firing.
The third row is why this PR does not depend on #6441: with the graceful wait
bounded, the guest is ACPI-capable by the time the request is re-sent, so
making the escalation terminate the domain saves nothing here. #6441 is
needed for a different failure, #6452, where the guest never becomes capable at
all -- there this PR is the one that changes nothing. The two are complementary
and neither subsumes the other.
Changelog notes
An application which is stopped very shortly after it starts is no longer held
for ten minutes before it is reported as stopped.
PR Backports
The
PVcase has leftfirstDelayatmaxDelaysince the switch was written,so every stable branch carries it.
Checklist
the budgets are internal to
doInactivate.architecture independent.