Skip to content

fix: vm lifecycle on UTM and auto-reload UTM#776

Merged
radkomih merged 2 commits into
mainfrom
fix-flaky-vm-setup-task
Jul 2, 2026
Merged

fix: vm lifecycle on UTM and auto-reload UTM#776
radkomih merged 2 commits into
mainfrom
fix-flaky-vm-setup-task

Conversation

@radkomih

Copy link
Copy Markdown
Contributor

Description

Encountered this multiple times:

Task vm:start (and vm:reset, which calls it) intermittently hangs or falsely reports a stopped VM as running. Three root causes, all stemming from treating utmctl exit codes as a proxy for UTM state:

  • Exit codes don't reflect VM state. utmctl status exits 0 even when the VM is stopped (only a missing VM is non-zero), and utmctl start exits 0 even when it never launched the VM. The old vm:start gated on utmctl status … && echo "running", so a stopped VM looked "running."
  • vm:reset raced UTM. It ran delete → clone → start separated by fixed sleeps, issuing the clone/start before UTM had finished updating its registry. Starting immediately after a clone can wedge UTM's Apple Event handler.
  • vm:download:golden left UTM stale. It copied the .utm bundle into UTM's Documents dir while UTM was running, which doesn't live-reload bundles - then aborted with a "please restart UTM manually" message, breaking any automated flow.

Changes

All in taskfiles/vm.yaml:

  • vm:start - gate on the reported run state (started / stopped) instead of exit codes. If the VM is still stopped, re-issue utmctl start (transient glitch), and only as a last resort relaunch UTM.app to clear a wedged start path before aborting with actionable guidance.
  • vm:reset - after delete, poll until utmctl status reports the VM is gone; after clone, poll until it reports stopped - so the start doesn't race a half-registered VM.
    • vm:download:golden - add a reload_utm helper that quits/relaunches UTM and waits until it's scriptable again, then verifies UTM sees the golden VM and continues, instead of aborting and asking the user to
      restart UTM by hand.

Testing

Verified manually

@radkomih radkomih self-assigned this Jun 25, 2026
@radkomih radkomih requested a review from a team as a code owner June 25, 2026 14:27
@radkomih radkomih requested a review from alex-au June 25, 2026 14:27
@swirlds-automation

swirlds-automation commented Jun 25, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@radkomih radkomih force-pushed the fix-flaky-vm-setup-task branch 3 times, most recently from 6601619 to b1b48ca Compare June 26, 2026 09:59
@brunodam brunodam requested a review from Copilot June 26, 2026 21:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves robustness of the local UTM VM workflow by avoiding reliance on utmctl exit codes as a proxy for VM state, reducing race conditions around clone/delete/start, and automatically reloading UTM so newly-copied .utm bundles are recognized without manual intervention.

Changes:

  • Make vm:start gate on the reported VM state (started/stopped) and retry utmctl start, with a final fallback of relaunching UTM.app.
  • Make vm:reset poll UTM’s registry after delete/clone to avoid racing half-registered VM entries.
  • Make vm:download:golden quit/relaunch UTM to force a registry reload after copying the golden bundle into UTM’s Documents directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread taskfiles/vm.yaml Outdated
Comment thread taskfiles/vm.yaml
Comment thread taskfiles/vm.yaml
Comment thread taskfiles/vm.yaml
@radkomih radkomih force-pushed the fix-flaky-vm-setup-task branch 3 times, most recently from a8511fe to b35713b Compare June 30, 2026 07:20

@brunodam brunodam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

radkomih added 2 commits July 2, 2026 09:18
…set, auto-reload UTM

Signed-off-by: Rado M <radkomih@gmail.com>
Signed-off-by: Rado M <radkomih@gmail.com>
@radkomih radkomih force-pushed the fix-flaky-vm-setup-task branch from fb95320 to d2f8467 Compare July 2, 2026 06:19
@radkomih radkomih merged commit 0d797ad into main Jul 2, 2026
19 checks passed
@radkomih radkomih deleted the fix-flaky-vm-setup-task branch July 2, 2026 07:30
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.

4 participants