Repository navigation
Reboot: reboot a Linux machine that holds a block inhibitor lock - #31
Merged
Merged
Conversation
A systemd block inhibitor lock made logind refuse the reboot. The coordinator put the reasons back and asked again each poll, so a lock nobody released held the machine, and any task waiting on it, forever. Root cannot skip the lock through logind: `systemctl -i` becomes a polkit question that needs an interactive answer. So when logind refuses, the agent starts reboot.target (or poweroff.target) through PID 1, which is what logind does once it agrees. A delayed action runs as a transient timer, fog-agent-reboot.timer, and wall sends the warning. The normal path is unchanged when no lock is held. Windows already overrides with shutdown.exe /f. Verified on the Debian 13 lab VM (systemd 257) with a block lock held: the old build fails both paths, the new build reboots on both. Fixes #30 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #30.
Problem. A systemd block inhibitor lock makes logind refuse the agent's reboot ("Operation denied due to active block inhibitor", or "Access denied" on some systemd versions). The coordinator retries each poll, so the machine never reboots and the task never runs.
Cause. Both paths go through logind:
shutdown +Nfor a delayed reboot,systemctl rebootfor an immediate one. logind enforces the lock. Root cannot skip it there:systemctl -iturns into a polkit check that needs an interactive answer.Fix. When logind refuses, start
reboot.target(orpoweroff.target) through PID 1 with--job-mode=replace-irreversibly. This is what logind does once it agrees, so the shutdown is orderly. A delayed action runs as a transient timerfog-agent-reboot.timer, andwallsends the warning. A second poll during the countdown reads as already in progress. With no lock held, the behavior is unchanged. This matches Windows, which already usesshutdown.exe /f.Verified on the Debian 13 lab VM (systemd 257), with
systemd-inhibit --what=shutdown --mode=blockheld by root:Failed to schedule shutdown: Access deniedCall to Reboot failed: Access deniedNot verified on Fedora/Rocky with the reporter's exact message. The fallback triggers on any refusal, so it does not depend on the message text.
🤖 Generated with Claude Code