Skip to content

Inhibit sleep/poweroff/reboot/hibernate when upgrading - #129

Open
Eeems wants to merge 3 commits into
masterfrom
issue/45
Open

Inhibit sleep/poweroff/reboot/hibernate when upgrading#129
Eeems wants to merge 3 commits into
masterfrom
issue/45

Conversation

@Eeems

@Eeems Eeems commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • System upgrades and image builds now prevent shutdown and sleep interruptions while running.
    • Improved terminal output handling provides clearer progress, status, and error messages across supported operations.
  • Bug Fixes

    • Progress display detection now works correctly when output is redirected or not connected to a terminal.
    • Upgrade status messages now appear with proper line breaks.
    • Upgrade validation now confirms operations remain protected from system interruption while active.

@Eeems Eeems linked an issue Aug 14, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Eeems, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 101 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f324c032-0988-45e5-a75b-159621200044

📥 Commits

Reviewing files that changed from the base of the PR and between 0f7c6ef and 5352bc9.

📒 Files selected for processing (3)
  • make/test.py
  • overlay/base/usr/lib/system/_os/cli/build.py
  • overlay/base/usr/lib/system/_os/cli/upgrade.py
📝 Walkthrough

Walkthrough

The daemon now acquires systemd inhibitor locks during upgrades and image builds. D-Bus output handlers support text and byte streams. CLI progress checks use standard output TTY status. The phase 2 test validates the inhibitor lock during an active upgrade.

Changes

Upgrade inhibition and output handling

Layer / File(s) Summary
Inhibitor context and daemon workflows
overlay/base/usr/lib/system/_os/system.py, overlay/base/usr/lib/system/_os/daemon/system.py, make/test.py
inhibit acquires and closes a logind inhibitor descriptor. Upgrade and image build workflows use the context. The phase 2 test checks the lock during the upgrade.
Byte-aware D-Bus output
overlay/base/usr/lib/system/_os/console.py, overlay/base/usr/lib/system/_os/dbus.py
Console handlers accept text or bytes. Pull, upgrade, and build callbacks use the handlers and emit newline-terminated status messages.
TTY-based progress checks
overlay/base/usr/lib/system/_os/cli/build.py, overlay/base/usr/lib/system/_os/cli/upgrade.py
Progress suppression checks sys.stdout.isatty(). The update-check message now includes a trailing newline.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: 🔵 Low · up to 0f7c6

The PR prevents suspend, hibernate, poweroff, and reboot while upgrades run. Merge is reasonable with explicit owner follow-up because background upgrade validation can produce ambiguous or unstable output/status handling, and inhibitor cleanup may mask an underlying error in an edge case.

Sequence Diagram(s)

sequenceDiagram
  participant Phase2Test
  participant os-daemon
  participant system.inhibit
  participant logind
  Phase2Test->>os-daemon: Start upgrade with --no-pull
  os-daemon->>system.inhibit: Acquire shutdown and sleep lock
  system.inhibit->>logind: Request inhibitor through D-Bus
  logind-->>system.inhibit: Return lock descriptor
  Phase2Test->>logind: Poll for os-daemon inhibitor lock
  os-daemon-->>Phase2Test: Complete upgrade
  Phase2Test->>Phase2Test: Combine upgrade and lock checks
Loading

Possibly related PRs

  • Eeems/arkes#96: Directly relates to CLI progress, console output callbacks, D-Bus operations, and daemon workflows.
  • Eeems/arkes#125: Introduces the phase 2 upgrade test modified here.
  • Eeems/arkes#126: Also modifies the phase 2 upgrade flow in make/test.py.

Poem

A rabbit guards the upgrade lane,
While logind locks the sleep domain.
Bytes and text now flow just right,
TTYs guide the progress light.
Hop, hop—builds stay safe tonight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: preventing sleep, poweroff, reboot, and hibernate during upgrades.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Eeems
Eeems marked this pull request as ready for review August 14, 2026 03:30
coderabbitai[bot]

This comment was marked as resolved.

@Eeems

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inhibit sleep/hibernate/poweroff when upgrading

1 participant