Skip to content

[13.4-stable] domainmgr: bound the graceful stop wait for default-mode guests - #6475

Merged
eriknordmark merged 1 commit into
lf-edge:13.4-stablefrom
eriknordmark:bound-graceful-shutdown-13.4-stable
Sep 8, 2026
Merged

eriknordmark merged 1 commit into
lf-edge:13.4-stablefrom
eriknordmark:bound-graceful-shutdown-13.4-stable

Conversation

@eriknordmark

@eriknordmark eriknordmark commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

Backport of #6453 to 13.4-stable.

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 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 PV case in doInactivate sets
doShutdown without lowering firstDelay from maxDelay the way HVM and
FML do. A guest which 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.

Such a guest now gets the same one-minute wait an HVM or FML guest already
gets, after which the stop escalates exactly as before. A xen PV guest keeps
the full budget, where the mode names a real paravirtualized guest whose tools
are inherent.

Cherry-picked with -x from b66b0040c, no adaptations: the pick applied
clean, and every added and removed line is identical to the master commit's --
the only difference against it is hunk-header line numbers. The buggy switch
block on this branch was character-identical to master's before the fix.

The second commit of #6453 is not backported. It adds an evetest test, and
evetest/ does not exist on this branch, so backporting it would mean
backporting the harness. The regression stays guarded here by the unit test
that ships in the cherry-picked commit.

PR dependencies

None.

How to test and validate this PR

TestShutdownBudget in pkg/pillar/cmd/domainmgr covers all eight
mode/hypervisor combinations. On this branch go build ./...,
go vet ./cmd/domainmgr/ and the full domainmgr test suite pass, and
gofmt -l is clean.

Validated against un-fixed code on 13.4-stable, the most divergent of the four
targets: reverting the PV arm to return true, maxDelay fails exactly the
two rows this change affects, PV under kvm and PV under kubevirt, with
firstDelay = 10m0s, want 1m0s, while both xen rows and the HVM, FML,
NOHYPER and LEGACY rows still pass.

End-to-end device measurements are in #6453: 637/636/637 s from deactivation to
HALTED before the fix against 98/95/96 s after, and 85 runs over 8 hours with
no outlier.

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

Checklist

  • I've provided a proper description
  • I've added the proper documentation -- no documented behaviour changes;
    the budgets are internal to doInactivate.
  • I've tested my PR on amd64 device -- the measurements in domainmgr: bound the graceful stop wait for default-mode guests #6453.
  • I've tested my PR on arm64 device -- not tested; the change is
    architecture independent.
  • I've written the test verification instructions
  • I've set the proper labels to this PR

For backport PRs:

  • I've added a reference link to the original PR
  • PR's title follows the template
  • I've checked the boxes above, or I've provided a good reason why I didn't
    check them.

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>
(cherry picked from commit b66b004)
@codecov

codecov Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 32.66%. Comparing base (8077a3d) to head (ca6ebb6).
⚠️ Report is 250 commits behind head on 13.4-stable.

Additional details and impacted files
@@               Coverage Diff               @@
##           13.4-stable    #6475      +/-   ##
===============================================
+ Coverage        24.78%   32.66%   +7.88%     
===============================================
  Files                8        9       +1     
  Lines             1138     1090      -48     
===============================================
+ Hits               282      356      +74     
+ Misses             788      654     -134     
- Partials            68       80      +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eriknordmark
eriknordmark marked this pull request as ready for review September 8, 2026 09:29
@eriknordmark
eriknordmark merged commit ebdd752 into lf-edge:13.4-stable Sep 8, 2026
43 checks passed
@eriknordmark
eriknordmark deleted the bound-graceful-shutdown-13.4-stable branch September 9, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stable Should be backported to stable release(s)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants