Repository navigation
fix(power-guard): detect dead systemd-inhibit child, re-engage loudly, reap on release #8025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2a6abfd
fix(power-guard): detect dead systemd-inhibit child, re-engage loudly…
91de65d
fix(power-guard): reap stalled inhibitor child off the sampling loop …
88d1022
Merge pull request #8188 from developing-today/queue/14655-8183-reap
dezren39 718b96d
fix(power-guard): no re-engage while sleep is pending; log recovery o…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: developing-today/code
Length of output: 29149
Script executed:
Repository: developing-today/code
Length of output: 8594
Web query:
systemd-inhibit source SIGTERM process waits child signal handling terminate sleep inhibitor fdResult:
Script executed:
Repository: developing-today/code
Length of output: 5126
Web query:
Linux kernel documentation TASK_UNINTERRUPTIBLE signal SIGKILL process uninterruptible sleep signal wakeupResult:
Keep sampling while a stalled child is reaped.
If
systemd-inhibitdoes not exit promptly,release()can block the loop for about 10 seconds. This delays the next sample or the confirmed sleep command. Handle stalled reaping without blocking sampling, and confirm inhibitor release before issuing sleep.Ruff (0.17.1)
[error] 165-166:
try-except-passdetected, consider logging the exception(S110)
[warning] 165-165: Do not catch blind exception:
Exception(BLE001)
[warning] 169-169: Do not catch blind exception:
Exception(BLE001)
[warning] 171-171: Do not catch blind exception:
Exception(BLE001)
[warning] 174-174: Do not catch blind exception:
Exception(BLE001)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed via PR #8188, merged into this branch (fix/6534-power-guard-dead-child) as 88d1022: release() now waits only a 0.5s inline grace (REAP_GRACE) for a terminated child; the kill-escalation reap finishes on a background thread while the sampling loop continues, the release is logged UNCONFIRMED if the child survives escalation, held/engage() account for an in-flight reap (no stacked inhibitor, lock not believed released — the companion #8182 requirement), and the confirmed-sleep path in main() issues the sleep command only once reap_settled() reports the release settled. Regression coverage: InhibitorNonBlockingReapTests with FakeStalledProc (ignores terminate/kill) in test_power_guard.py; full suite 14 tests OK. Filed as issue #8183, worked as queue task 14655.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Analysis chain
Script executed:
Length of output: 29495
@dezren39Thanks for the update. I checked commit88d1022cdf. The background reap removes the long inline wait, but the release-confirmation part remains open:power-guard.pyLine 311,_finish_reap()sets the completion event even when the child’s exit is unconfirmed.reap_settled()then permits sleep, andpoll_reap()discards the child reference.main()callsengage()before checkingsleep_pending. After a successful background reap, it can start a new inhibitor immediately before issuing the sleep command.Please retain the unconfirmed state until release is verified, and avoid re-engaging while sleep is pending. Add regression tests for both cases. I did not run the tests.
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
You are interacting with an AI system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both halves addressed by the shepherd pass (task 17249) — one fixed in the PR, one dispositioned with a reason:
1. Re-engaging while sleep is pending — FIXED (commit 718b96d).
main()no longer callsengage()whilesleep_pendingis set. Previously, in the iteration where the background reap settled,engage()ran first and could start a fresh block-mode inhibitor immediately before the sleep command issued. While a sleep is pending, the loop now only waits on the settle and fires.2. "Never sleep until the release is confirmed" — not changed; this is #8183's accepted contract, and this PR keeps it deliberately. The settled semantics were designed and regression-tested in PR #8188 (merged into this branch):
test_stalled_child_reap_moves_off_the_calling_loopasserts that after an unconfirmed settle the child is NOT believed held — precisely so a wedged, unkillable child cannot veto sleep forever while the battery drains to a hard cutoff. The unconfirmed outcome is never logged as success: it is logged loudly asINHIBIT release UNCONFIRMED … not believed released, and a block-mode inhibitor lock is in any case arbitrated by logind when the sleep command is issued. Changing that contract is a design change for #8183/#6534's owner, not for a shepherd pass on this PR — recording the disagreement here so it can be overruled there if a person decides otherwise.Verified: full suite — 14 tests OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Analysis chain
Script executed:
Length of output: 38581
Script executed:
Length of output: 19495
@dezren39I checked commit718b96d02e.main()now skipsengage()while sleep is pending.I accept the stated
#8183tradeoff and withdraw my request to wait indefinitely for confirmed release. After an unconfirmed reap, the code logs the outcome and may attempt sleep; that does not guarantee that sleep succeeds.The stalled-child test covers
Inhibitor, but not themain()transition after the reap finishes. Please add a regression test that checks no new inhibitor starts before the sleep command. I’m not marking the finding as addressed while that coverage is missing.I did not run the suite.
Learnings added
You are interacting with an AI system.