Skip to content

power-guard: invalid timing override crash-loops under Restart=always — add RestartPreventExitStatus=2 #6502

Closed

Description

@dezren39

Problem

The power-guard daemon validates its timing overrides at startup and exits with status 2 on an invalid value (timing_from_env in nixos/services/power-guard/power-guard.py — the only SystemExit(2) source in the daemon), specifically so a misconfigured unit "shows as failed instead of crash-looping" (docstring, #6477). But the NixOS service in nixos/services/power-guard/default.nix sets Restart = "always" with RestartSec = "10s" and no RestartPreventExitStatus, so an invalid override actually crash-loops the unit every 10 seconds forever, repeating the startup error — the opposite of the intended end state.

Found by CodeRabbit review on PR #6485 (comment 4491161487); deliberately not folded into that PR because task 10951's packet keeps NixOS service configuration out of scope.

Fix

Add RestartPreventExitStatus = 2; to serviceConfig in nixos/services/power-guard/default.nix, so the invalid-override exit leaves the unit failed.

Acceptance criteria

  • default.nix serviceConfig includes RestartPreventExitStatus = 2.
  • Verified safe: exit status 2 in the daemon arises only from the invalid-timing path (grep SystemExit — one site, timing_from_env); normal operation and other exits are unaffected.
  • The power-guard test suite (scripts-test / test_power_guard.py) still passes; if a Nix-level check exists for the module, it passes too.

Evidence

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/normalOrdinary priority (the default)
    on Nov 6, 2026
  2. developing-today commented on Nov 6, 2026

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

    @dezren39
    MemberAuthor

    🤖 Agent note · done

  5. added
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 6, 2026
  6. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  7. added
    work/assignedQueue worker lifecycle state
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed on Nov 6, 2026
  8. 5 remaining items

  9. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 6, 2026
  10. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    task 11031 parked: PR #6517 opened (branch queue/11031-6502-power-guard-restart-prevent, commit 18c28ed) with the one-line RestartPreventExitStatus = 2; fix. Targeted tests pass (unittest suite: 8 tests OK; nix parse OK). CI (basic: scripts-test 3.12/3.14) still pending after the 5-minute poll window, so task 11031 is parked 1200s; on resume, recheck PR #6517 checks and merge when green.

  11. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  12. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    task 11031 done (fixed_merged): PR #6517 merged 2026-11-06T14:00:04Z (merge commit d87538f) — one-line change adding RestartPreventExitStatus = 2; to serviceConfig in nixos/services/power-guard/default.nix, closing issue #6502. Verification: diff verified fresh (exactly the intended line); targeted tests passed on laptop (python3 -m unittest power-guard suite — 8 tests OK; nix-instantiate --parse default.nix OK). CI note: PR checks (basic: scripts-test 3.12/3.14, run 42225883557) sat queued/unstarted ~30 min (runner backlog, no failure); merged under Drew's merge authority (verified work does not wait on queued CI) — main-branch CI will exercise the change. Codex gate: Codex review failed on usage limits with zero inline findings — nothing to disposition.

  13. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 6, 2026
  14. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

    Issue #6502 was closed 2026-11-06T14:00:06Z by PR #6517 merged 2026-11-06T14:00:04Z (merge commit d87538f) under task 11031 — the one-line RestartPreventExitStatus = 2; fix, verified in that task's closing note (targeted unittest suite 8 tests OK; nix parse OK). This triage task (task 11117) therefore completes as already_done/superseded with no new work.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/power-guardnixos/services/power-guard battery confirmation daemonarea/nixosNixOS modules and machine configurationkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)status:donetask/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions