Skip to content

feat: automate the disk-VM lifecycle end to end - #37

Merged
NovusEdge merged 4 commits into
mainfrom
lifecycle-auto
Aug 10, 2026
Merged

feat: automate the disk-VM lifecycle end to end#37
NovusEdge merged 4 commits into
mainfrom
lifecycle-auto

Conversation

@NovusEdge

Copy link
Copy Markdown
Owner

Part 2 of the plan. One stoat up now takes a disk VM from install to a provisioned, input-working desktop with no manual restarts.

Auto-restart after install (internal/core/autorestart.go): AutoRestartAfterInstall waits for the install poweroff (waitStopped), then restarts the VM so it boots the disk. The guard (disk && !Installed && qemu.Running) self-disarms after the install flip, so exactly one restart happens. A successful install powers off (QEMU exits via -no-reboot); a failed install leaves the installer running, so the watcher rides out InstallTimeout (15m) and gives up silently.

  • CLI: stoat up on an uninstalled disk VM prints installing <vm>..., blocks on the watcher, then falls through to the existing apply. --no-apply skips the apply, not the restart.
  • TUI: awaitInstall mirrors awaitSSH; vmStartedMsg batches it for an installing disk VM, and installRestartedMsg chains into awaitSSH → apply.

Reboot once for udev (internal/core/apply.go): recipes gain a reboot = true manifest field. After the recipes run, if one that ran declared it, rebootAndWait reboots the guest over ssh and waits for it to come back. The xfce recipe sets it, since setup-devd udev only takes effect at the next boot. One reboot regardless of how many recipes ask.

Net: stoat up <alpine disk vm + xfce> → installer → auto-restart → apply → reboot once → a clickable desktop.

Known limitation: rebootSettle (2s) is a guess to keep waitReachable from catching the pre-reboot sshd. Real reboot timing needs a live VM to confirm; I'll validate and tune it in an E2E pass. If it returns early, the guest still reboots and udev still takes effect — only the "ready" signal would be premature.

Tests: autorestart_test.go (guard, timeout-silent, stop-triggers-restart), apply_reboot_test.go (reboot-and-wait via a fake ssh + fake sshd, no real ssh), manifest reboot parse, TUI branch/installRestartedMsg. just check and just test pass.

qemu.Start only flips Installed at the NEXT start, and the installer's
poweroff just exits QEMU (-no-reboot). Nothing brought the disk itself
up until now: a user had to run `stoat up` a second time by hand.

AutoRestartAfterInstall waits for the installer to power off, then
restarts the VM so it boots the disk. The guard disarms itself after
one restart, since the next load sees Installed already true.
`stoat up` used to leave a fresh disk VM's install running and exit;
the disk never booted until a second, manual `up`. up now blocks on
AutoRestartAfterInstall before its usual post-boot apply, so one `up`
carries the VM from installer to a provisioned system.
The TUI already auto-applies once a VM answers ssh; an uninstalled
disk VM never reached that path, since needsAutoProvision excludes it
on purpose (its sshd belongs to the installer, not the system).

awaitInstall watches for the installer to power off in the
background, the same way awaitSSH already watches for reachability,
so the program stays responsive during the wait. Once the restart
lands, installRestartedMsg hands off into the existing awaitSSH watch.
xfce's install-alpine.sh switches Alpine from mdev to udev
(setup-devd), a change OpenRC only picks up at the next boot; without
it Xorg finds no mouse or keyboard. A manual restart was the only fix.

recipe.toml gets a reboot=true flag. Apply reboots the guest once,
after every recipe in a run has succeeded, when any of them declared
it, and waits for the guest to answer ssh again before returning.
@NovusEdge NovusEdge added the enhancement New feature label Aug 10, 2026
@NovusEdge NovusEdge self-assigned this Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 32 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: ASSERTIVE

Plan: Pro Plus

Run ID: a016209d-b9c6-4558-b7d2-98765b3109e5

📥 Commits

Reviewing files that changed from the base of the PR and between 945b332 and 9504b8e.

📒 Files selected for processing (12)
  • internal/cli/run_vm.go
  • internal/core/apply.go
  • internal/core/apply_reboot_test.go
  • internal/core/autorestart.go
  • internal/core/autorestart_test.go
  • internal/core/wait.go
  • internal/recipes/bundled/xfce/recipe.toml
  • internal/recipes/manifest.go
  • internal/recipes/manifest_test.go
  • internal/tui/app.go
  • internal/tui/autoprov.go
  • internal/tui/autoprov_test.go

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.

@NovusEdge
NovusEdge merged commit 7b084b2 into main Aug 10, 2026
7 of 8 checks passed
@NovusEdge
NovusEdge deleted the lifecycle-auto branch August 10, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant