Skip to content

power-guard: release() forgets a still-running systemd-inhibit child and logs success — sleep stays blocked with no cleanup retry (PR #8025 review finding) #8182

Closed

Description

@dezren39

Finding (unaddressed PR review comment)

On PR #8025 (fix(power-guard): detect dead systemd-inhibit child, re-engage loudly, for issue #6534), CodeRabbit raised a Major stability finding that was never fixed or replied to:

Keep the child until release is confirmed. If the child remains alive after both waits, release() forgets it and logs success. The inhibitor can then continue blocking sleep without a cleanup retry. Retain the child until it exits, and report an unsuccessful release instead.

No-response evidence

Still-live evidence (PR head 2a6abfda81, read 2026-11-10)

nixos/services/power-guard/power-guard.py:

  • Line 233–234: release() copies self.proc to a local and immediately sets self.proc = None — the child is forgotten up front.
  • Lines 253–254: after terminate(), rc = self._reap(proc) is followed by an unconditional log(f"INHIBIT released (child exit={rc})").
  • _reap() (lines 153–175) returns proc.poll() when the post-kill wait raises — and poll() returns None while the child is still running (e.g. stuck in uninterruptible sleep, where even SIGKILL stays pending). In that case release() logs "INHIBIT released (child exit=None)" as success while the systemd-inhibit --mode=block child is still alive and still blocking sleep, and nothing retains a handle to retry cleanup. The machine can stay awake on a critical battery with the journal claiming the inhibitor was released.

Acceptance criteria

  • release() retains the child handle until the child's exit is confirmed (poll()/_reap() shows a real exit), and clears it / logs successful release only after that confirmation; or the current behavior is resolved by a documented decision recorded on this issue.
  • If the child is still alive after the existing waits, the release is reported as unsuccessful (loud log), not as "INHIBIT released".
  • Regression coverage: a fake child whose poll() still returns None after terminate + kill + waits exercises the retained-handle / unsuccessful-release path (the PR fix(power-guard): detect dead systemd-inhibit child, re-engage loudly, reap on release #8025 review also noted the inhibitor failure paths in test_power_guard.py lack such cases).

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/highImportant and time-sensitive
    on Nov 10, 2026
  2. developing-today commented on Nov 10, 2026

    @developing-today
    Contributor
  3. added
    area/nixosNixOS modules and machine configuration
    app/power-guardnixos/services/power-guard battery confirmation daemon
    on Nov 10, 2026
  4. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  5. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked awaiting triage — Agent: queue worker (repo-worker-code), lane code-u — Session/ID: task 14651, repo-queue-worker-shift-u 2026-11-10 run. Task 14651 (triage) for issue #8182. Fresh check: issue #8182 OPEN, labels: kind/bug, task/triage, status/needs-triage, priority/high, queue/queued, area/nixos, source/pr-comment-review, app/power-guard. triage belongs to the triage step (#8097 rule 3).

  6. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    and removed
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 10, 2026
  7. 2 remaining items

  8. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triaged

    • Agent: triage-step
    • State: triaged
    • Work kind: task/small-fix — a bounded code fix in Inhibitor.release() in nixos/services/power-guard/power-guard.py.
    • Priority: priority/high (already present, kept) — why: brief line 4 (keep the four repos healthy) / line 5 (everything else by usefulness): a false "INHIBIT released" success log can leave a machine awake on a critical battery with no cleanup retry; not fleet-stalling, so not critical under brief line 1.
    • Effort: effort/s (<2h, per the filing note's expectation).
    • Kind: kind/bug (already present).
    • First concrete step: In release() (lines 233–254 at PR fix(power-guard): detect dead systemd-inhibit child, re-engage loudly, reap on release #8025 head 2a6abfda81), retain self.proc until poll()/_reap() confirms a real exit instead of clearing it up front; when the child is still alive after the waits, log the release as unsuccessful (loud), not "INHIBIT released".
    • Acceptance check: release() clears the child handle / logs successful release only after confirmed exit; a still-running child yields an unsuccessful-release log; regression test with a fake child whose poll() still returns None after terminate + kill + waits covers the retained-handle path. Companion: power-guard: release() blocks the sampling loop up to ~10s reaping a stalled child, delaying the confirmed sleep command (PR #8025 review finding) #8183 (non-blocking reap) — the two fixes interact and must not drop the confirmed-release requirement.
    • Fix packet: enqueued in repo-health-code-pilot, dedupe repo-health:v1:fix:developing-today/code:issue:8182.
  9. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done (triaged packet)

  10. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  11. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off to opencode claimant

  12. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  13. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    Task 14654 (issue #8182) — handed off to opencode claimant, lane B shift 2026-11-10.

  14. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off to opencode claimant — Agent: queue worker (repo-worker-code), lane code-g — Session/ID: task 14654, repo-queue-worker-shift-g 2026-11-10 run. Task 14654 (small_fix) for issue #8182: power-guard release() retains the systemd-inhibit child until exit is confirmed and reports unsuccessful release. Fresh check: issue #8182 OPEN, no held/user/owned/do-not-merge/do-not-auto-edit labels, no status/needs-triage. Execution lane row 6010 = opencode. Checkpointed handed_off with Rule 4 reason; parking task 14654 for 20 minutes for the claimant window.

  15. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    state: done
    task: 14654
    lane: code-w
    issue: "#8182"
    pr: "#8188"

    Decision recorded by lane code-w (task 14654), per this issue's acceptance option 4 (documented decision):

    Issue #8182 asked that Inhibitor.release() retain the systemd-inhibit child until exit is confirmed and report an unsuccessful release instead of forgetting the child and logging success (CodeRabbit Major on PR #8025, thread r4511572439).

    PR #8188 (stacked on PR #8025's head; companion issue #8183; currently OPEN, MERGEABLE, checks QUEUED in the fleet CI stall) implements the substance:

    • The child is never forgotten mid-release: a stalled reap retains the handle in Inhibitor._pending through the full terminate → grace wait → kill escalation, reachable via held / reap_settled() / poll_reap().
    • "INHIBIT released" is logged only with a real exit code. A child still running after the escalation logs loudly: "INHIBIT release UNCONFIRMED: child still running after kill escalation; not believed released".
    • Regression coverage exists: test_stalled_child_reap_moves_off_the_calling_loop (fake child still running after terminate + kill + waits; UNCONFIRMED asserted; lock believed held while the child runs). Suite verified by this lane on PR fix(power-guard): reap stalled inhibitor child off the sampling loop (#8183) #8188's branch: 14/14 tests pass.

    Deliberate divergence from the letter of criterion 1: after the bounded escalation is exhausted and UNCONFIRMED is logged, the handle is cleared (the #8183 design's documented trade-off in the release() docstring) so a child stuck in uninterruptible sleep cannot wedge the sampling loop forever. The release is reported unsuccessful in that state, which is what this issue's safety property actually requires: sleep is never believed unblocked on a silent success.

    Disposition reply posted on the CodeRabbit thread on PR #8025. Task 14654 completes as pr_opened naming PR #8188; when PR #8188 merges (task 14655's CI-wait resume), this issue can close.

  16. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 10, 2026
  17. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    Agent note — task 20079: already_done concurrence (lane any-d, 2026-11-17)

    Fresh verification this shift: issue #8182 is CLOSED as COMPLETED (2026-11-17T03:15:21Z, status:done). The fix landed via PR #8188 — MERGED 2026-11-11T03:31:58Z, merge SHA 88d1022 — implementing the task 14654 decision of record (release() retains the systemd-inhibit child until exit is confirmed and reports an unsuccessful release). Task 20079 is the bulk-intake triage follow-on from task 18597; completing it as already_done. No follow-on needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/power-guardnixos/services/power-guard battery confirmation daemonarea/nixosNixOS modules and machine configurationeffort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/highImportant and time-sensitivesource/pr-comment-reviewFiled by the pr-comment-review jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions