Repository navigation
Deploy tool: safe mode counts each start from its first moments - #340
Merged
Merged
Conversation
Safe mode turns our tools' units off after three failed starts of the head unit in a row, whatever ends each start, and the start after the third already runs without them. - safe_mode.sh's first step, at the very start of each start, counts the start as failed until it stays up 5 minutes or shuts down in order. A start that ends with no orderly shutdown at all (a power cut, a reset, a hang that is reset) counts, and so does a crash restart up to 5 minutes in: the crash handler restarts the head unit about a minute and a half after a crash, so a program crashing early in every start ends each start some 2 to 3 minutes in. - When the third failed start ends without a shutdown mark, the next start's first step writes the flag. Every tool unit that is off in safe mode starts after that step (its limits drop-in orders it after mgu-deploy-safe-mode.service). - An orderly stop of the system (systemctl reboot or poweroff), which runs no var-opt-ro.service, counts as a shutdown without a restart record: the guard's unit marks it from its ExecStop. - The count and the flag are on disk before the first step returns. - An install cut short between moving a tool's version folder aside and putting the new one in place gets the folder back, where current points, at the deploy tool's next changing run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
robertnisipeanu
force-pushed
the
power-loss-safe-updates
branch
from
November 19, 2026 12:13
8e81d30 to
fb9c595
Compare
Owner
Author
|
Released as mgu-deploy 0.8.26. The rest of the power-cut runs on the iDrive 7 test unit:
|
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.
The deploy tool's safe mode counts every start of the head unit as failed from its first moments, so a head unit that keeps restarting soon after it starts ends up with our tools' units off, whatever ends each start, and the start after the third failed one already runs without them.
Why. Safe mode decided at the shutdown (var-opt-ro.service) whether a start failed, and counted only crash restarts within 2 minutes of the start. On an iDrive 7 test unit:
What changes
safe_mode.sh startruns first at each start (the guard'sExecStartPre) and writes the start as failed (<before> <boot id> <before + 1>), on disk before it returns. What follows decides: a start up 5 minutes clears the count; the shutdown mark counts a restart recmgr or crashhandler asked for within 5 minutes; a shutdown without a restart record neither counts nor clears within 5 minutes and clears after; a restart our tools asked for clears. A start that ends with no mark keeps its count.After=mgu-deploy-safe-mode.servicein its limits drop-in, so the flag that step writes holds in the same start: the controller gate's guard (no preload), the page template units, the renderers. On the test unit the step took about 0.25 s, and the template and gate units started right after it.systemctl reboot,poweroff), which runs no var-opt-ro.service, as a shutdown without a restart record (ExecStop,Conflicts=shutdown.target).boot(start, then the crash statistics baseline) stays for the guard unit an earlier deploy tool laid; the new unit runsstartinExecStartPreand the statistics read inExecStart, so our units wait only for the count.<version>.old-<pid>) and putting the new one in place gets the folder back wherecurrentpoints, at the deploy tool's next changing run. The aside was deleted as a stale file, which leftcurrentpointing at nothing.Safe mode keeps the provisioning fallback and app-privacy's MainApp patch: they list the Store, whose Leave safe mode ends it, and MainApp failing does not restart the head unit (the app manager's supervisor starts it again).
AI: Claude Code, Claude Opus 5.5
Tested:
deploy/test/run.sh(Docker, unit code on Node 8.16.2): 1457 of 1462 pass. The 5 others are timing checks of the app manager bounce (testBounceGuard,testIdleWait,testInplace) that failed under host load; run again on their own they pass, 53 of 53, on this branch and on main alike.systemctl rebootmarkednormal; no ordering cycles at any start.Human review: No person reviewed this diff before it was opened.
Screenshots: n/a
🤖 Generated with Claude Code