Skip to content

cli: prepare the restart config the same way as start - #1645

Open
somaz94 wants to merge 1 commit into
abiosoft:mainfrom
somaz94:fix/restart-prepare-config
Open

somaz94 wants to merge 1 commit into
abiosoft:mainfrom
somaz94:fix/restart-prepare-config

Conversation

@somaz94

@somaz94 somaz94 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Refs #1561

Problem

With COLIMA_SAVE_CONFIG=0 and a partial, read-only colima.yaml (the Nix setup in #1561), colima start works but colima restart stops the VM and then fails, leaving it stopped. With this file:

cpu: 2
memory: 2
disk: 20
runtime: containerd
vmType: vz

restart ends with:

Resize instance colima-r1561's disk from 20GiB to 0B
disk shrinking is not supported

Cause

colima start runs prepareConfig first, which fills in the flag defaults, the template and the fixed settings. colima restart passed the file to app.Start exactly as it was read. With the default COLIMA_SAVE_CONFIG=1 that file is the full config saved by the last start, so nothing is missing. With a partial file, restart starts with rootDisk: 0, so Lima tries to shrink the root disk, and with binfmt unset, which skips the binfmt setup.

Fix

restart now prepares the config with the same prepareConfig as start and validates it before stopping the VM, so a config that fails validation no longer leaves the VM stopped. It still never writes the config file. When the file is missing or has no runtime, prepareConfig would ignore it and use plain defaults, which can grow the data disk (for example after COLIMA_SAVE_CONFIG=0 colima start --disk 60), so restart uses the config the instance last started with instead. An unreadable file is still an error, as before.

Testing

Test_restartConfig covers a partial file, a missing file and an unreadable file, and the first two fail on main. go test ./... passes on macOS and in a golang:1.26.1 Linux container, and golangci-lint v2.11.3 reports no issues for darwin and linux. I also reproduced the issue on macOS 14 (Apple Silicon, vz, containerd) with the file above: restart fails on main as shown and works with this change whether the VM is running or stopped. With the file moved away, it restarts with the instance's last config and the data disk stays at 20GiB.

The networks.yaml and colima list symptoms in #1561 are not covered here.

AI disclosure: all of the code and tests in this PR were written with Claude Code (Claude Opus 5.5), and the checks above were run through it. I reviewed the whole diff before opening this PR.

Signed-off-by: somaz <genius5711@gmail.com>
somaz94 added a commit to somaz94/somaz94 that referenced this pull request Oct 6, 2026
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.

1 participant