Repository navigation
feat(supervise): wsl --shutdown sticks: go idle instead of restarting (#518) - #519
Merged
Merged
Conversation
…#518) When the engine's distro stops while this supervisor was watching it run and nobody asked for a stop, the engine is left down and marked idle, and the next docker command wakes it. A dockerd crash with the distro still running is restarted as before. So is every stop Skrog requests itself, and a supervisor that never saw the engine run. The verdict is latched at the first down observation. A distro state that cannot be read counts as a crash. snapshot save runs its export under a maintenance hold, so the engine comes back afterwards as it did. Closes #518
zcsizmadia
force-pushed
the
feat/wsl-shutdown-sticks
branch
from
October 5, 2026 16:59
551ad77 to
f38c79e
Compare
zcsizmadia
marked this pull request as ready for review
October 5, 2026 16:59
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.
#518:
wsl --shutdownsticks. When the engine's distro stops while the supervisor was watching it run and nobody asked for a stop, the engine is left down and marked idle. The nextdockercommand wakes it through the existing demand path. A dockerd crash, where the distro keeps running, is still restarted.## The rule, and why it's about a change and not a stateAn audit of every place Skrog itself stops the engine found that "distro stopped + desired running" is the normal state in front of a start:-skrog startandskrog restart- logon autostart after a reboot-restart --supervisor- a daemon.json bounce- a snapshot restore under a supervisorA rule that checked the distro on every tick would strand all of those. So:-sawUpis true only while this process has watched the engine run with desired running.- It's cleared by: - a stop request, in either desired-stopped branch - the supervisor's own idle stop - a maintenance hold - deciding a down engine was a crash- On the first down observation withsawUpset, the supervisor asks the new optionalDistroProberwhether the distro is running. The answer is latched, and it's asked once. - Distro stopped: writeEngineIdleand leave the engine down.skrog statusreportsidle, andDemandwakes it. - Distro running, or the probe fails: restart, as before. "Cannot tell" is a crash, because guessing "stopped on purpose" wrongly would leave a crashed engine down.- AnEnginewithoutDistroProberbehaves exactly as before. All existing supervisor tests use such an engine and are unchanged.Provisioner.DistroRunninganswers from the WSL listing only, never an exec (an exec would boot the distro, #82). An unregistered distro is an error, not "stopped".##snapshot saveThe snapshot package sayswsl --exportterminates the distro and "the supervisor brings it back". I haven't re-verified that. The export now runs under a maintenance hold (the mechanismengine upgradeuses), so the engine comes back afterwards either way. The hold also stops the supervisor probing, and so booting, the distro mid-export.## Behaviour change to knowContainers with a restart policy used to come back after awsl --shutdownby themselves. They now wait for the nextdockercommand. Whether a sleep/resume ever stops the distro isn't measured; if it does, the same applies. This is in the CHANGELOG and theRuncomment.## Testsinternal/supervise/outsidestop_test.gocovers:- an outside shutdown leaves the engine down and idle, andDemandstarts it- a daemon crash with the distro up is restarted- a fresh supervisor starts a stopped distro- stop-then-start is a start- a stop during a hold is restarted- unknown distro state restarts- a crash in backoff isn't later read as a shutdown- an engine without the probe still restartsinternal/provision/distrorunning_test.go: listing-only, and unknown or unregistered is an error.Mutation-checked, each failing at least one test:- The naive rule (nosawUpgate) fails four tests: fresh supervisor, stop-then-start, hold, and backoff latch.- No latch- Idle not written to the file- A hold keepingsawUp- A requested stop keepingsawUp- An unknown distro state read as stopped- An unregistered distro read as stoppedDocs:skrog superviseandskrog proxyhelp, README,docs/auto-logon-runner.mdanddocs/cli-json.md(idlenow also means this) no longer promise recovery fromwsl --shutdown. CHANGELOG entry under Changed.lint.ps1, the drift checks (regenerated),build-docs.ps1 -Strictandcheck-links.ps1pass.## Live acceptance (from #518, not yet run)- [x] Supervisor running, engine up,wsl --shutdown→skrog-enginestill stopped a minute later (onmain: running again within seconds), andskrog statussaysidle.- [x] The nextdocker pswakes it and succeeds.- [x] Killing dockerd inside the distro still restarts it.- [x]skrog restart,skrog config set engine.<key>,snapshot saveandsnapshot restoreeach bring the engine back.Closes #518Live acceptance, run 2026-10-05 on WSL 3.0.1
This branch's build, stacked on #521 (idle-timeout 5m), supervising the maintainer's real install:
wsl --shutdown: the engine stayed down,skrog statussaididle, and the distro was Stopped for 80 s and more.docker pswoke it and succeeded in 6 s.kill -9of dockerd (pid 30), with the distro up: restarted as pid 392 within 5 s.skrog restart,config set engine.max-concurrent-downloads 3and clearing it again (two daemon.json bounces),snapshot save(7.4 GiB) andsnapshot restore: each left the enginerunning, with docker answering. 24 images before and after the restore.This also fixes a 0.8.0 bug, seen live today: after
snapshot saveunder the 0.8.0 supervisor, the engine stayedstoppedwithdesired runningand the distro running, anddockerfailed untilskrog start. With this branch,snapshot savebrought the engine back. The CHANGELOG entry, which claimed the engine "comes back afterwards as it did", is corrected.Rebased onto main after #521 and #526 (CHANGELOG only); the full suite passes.