mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
A review of the remount restart found its failure paths loose: - A restart whose limactl stop failed returned the plain message, and the caller then stopped the VM's proxy with the VM still running. Now a folder still mounted with the old mode is warned of and the VM goes on with its proxy, and anything else fails as a logged stop_failed, saying the VM didn't stop. - The interrupt's cleanup was dropped before the restart's stop, so a Ctrl+C during that stop could leave an open-tier VM running. It now stays until any stop in remountProject returns. - The start again repeated the first start's warnings (policy lines, pins, a degraded start). The UI now says each warning once a run, by its name and values, which covers every package's warnings without a flag through each of them. - mount_cache_unmounted and mount_cache_unchecked come only after the restart failed, so they no longer say to run devvm restart: they say the VM is stopped and its console log may say why. mount_cache_remount_failed says the old mode can lose writes and what may hold the folder. Their doc links stay on "When the cache mode changes", which now points to the console log. - The mountinfo check's comments and docs say why it's used (portable: any awk, no util-linux tool but mountpoint), not that Alpine lacks findmnt, which devvm's base layer installs there. - design.md: the stop that fails, the warnings said once, the cleanup through the stop, and the older race of another devvm starting the VM in the gap, which fails closed. Tests: TestRemountRestartStop (the cleanup held through the stop; a stop that fails, mounted or not), TestRemountRestartConfined (each start's undoStart, an interrupt between the starts: one start, the proxy stopped, the one undo kept; a start again whose proxy fails), TestWarnOnce, and mount_cache.txtar's allowlist restart warning of a bad policy line once. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HTFcPrY8FzzQMopN5wgpLQ
213 lines
9.5 KiB
Plaintext
213 lines
9.5 KiB
Plaintext
# devvm mount-cache [none]: how a VM caches its project folder's mount,
|
|
# which on a Linux host QEMU's 9p does. A new VM gets none, the one mode
|
|
# devvm sets; a VM whose mode nobody chose keeps Lima's mmap untouched,
|
|
# warned of at each launch, until devvm mount-cache none switches it from
|
|
# its next start, which makes it in one edit and mounts the folder again.
|
|
# On macOS the backend has no such choice.
|
|
|
|
cp $WORK/features-none.json $DATA/settings.json
|
|
|
|
# No VM yet; a mode that isn't none, and a value with --json, are refused
|
|
# before devvm looks for one.
|
|
project web
|
|
! exec devvm mount-cache
|
|
stderr '^devvm: no_vm_mount_cache dir=\S*/web$'
|
|
! exec devvm mount-cache mmap
|
|
stderr '^devvm: mount_cache_invalid value="mmap"$'
|
|
stderr '^usage_help command=devvm mount-cache$'
|
|
! stderr no_vm_mount_cache
|
|
! exec devvm mount-cache loose
|
|
stderr '^devvm: mount_cache_invalid value="loose"$'
|
|
! exec devvm mount-cache none none
|
|
stderr '^devvm: args_too_many '
|
|
! exec devvm mount-cache --json none
|
|
stderr '^devvm: json_shows_only command=devvm mount-cache$'
|
|
! exec devvm mount-cache -g
|
|
stderr '^devvm: flag_unknown '
|
|
|
|
# A new VM gets none: on Linux it's in its state, and its project folder
|
|
# is mounted with it as it's made.
|
|
stub_reset
|
|
exec devvm --network open --no-git-protect
|
|
! stderr mount_cache_unchosen
|
|
vm_name WEB web
|
|
vm_state $WEB_dir/vm.json
|
|
[linux] stdout '^mount\.cache=none$'
|
|
[darwin] ! stdout '^mount\.'
|
|
stub_calls
|
|
[linux] stdout '^limactl clone --tty=false \S+ devvm-web-[0-9a-f]{14} --mount-none --set \.mounts = \[\{"location":"\S*/web","writable":true,"9p":\{"cache":"none"\}\},'
|
|
[darwin] stdout '^limactl clone --tty=false \S+ devvm-web-[0-9a-f]{14} --mount-none --set \.mounts = \[\{"location":"\S*/web","writable":true\},'
|
|
|
|
# macOS: the VM's mode is refused, to show or to change.
|
|
[darwin] ! exec devvm mount-cache
|
|
[darwin] stderr '^devvm: backend_lacks backend=lima feature=mount-cache vm=devvm-web-[0-9a-f]{14}$'
|
|
[darwin] ! exec devvm mount-cache none
|
|
[darwin] stderr '^devvm: backend_lacks backend=lima feature=mount-cache vm=devvm-web-[0-9a-f]{14}$'
|
|
[darwin] stop 'the rest is a Linux host''s'
|
|
|
|
# Running: its mode, chosen, as it has it.
|
|
exec devvm mount-cache
|
|
stdout '\Anone\n\z'
|
|
! stderr .
|
|
exec devvm mount-cache --json
|
|
stdout '\A{\n "version": 1,\n "mode": "none",\n "chosen": true\n}\n\z'
|
|
exec devvm mount-cache none
|
|
stdout '^==> vm_mount_cache mode=none vm=devvm-web-[0-9a-f]{14}$'
|
|
|
|
# A VM whose mode nobody chose, as one made before devvm chose it: none
|
|
# in its state, and Lima's mmap on its mount. Its start leaves the mount
|
|
# as it is, and each launch warns.
|
|
exec limactl stop $WEB
|
|
json_set $WEB_dir/vm.json mount:={}
|
|
exec sh -c 'limactl edit "$1" --set ".mounts = [{\"location\":\"$(pwd -P)\",\"writable\":true},{\"location\":\"$DATA/tools\",\"mountPoint\":\"/mnt/devvm-tools\",\"writable\":false}]"' sh $WEB
|
|
stub_reset
|
|
exec devvm
|
|
stderr '^devvm: mount_cache_unchosen mode=mmap vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl edit'
|
|
exec devvm
|
|
stderr '^devvm: mount_cache_unchosen '
|
|
exec devvm mount-cache --json
|
|
stdout '"mode": "mmap",\n "chosen": false'
|
|
stderr '^devvm: mount_cache_unchosen '
|
|
|
|
# Running, devvm mount-cache none waits for its next start.
|
|
stub_reset
|
|
exec devvm mount-cache none
|
|
stderr '^devvm: next_start count=1 vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl (edit|stop)'
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^mount\.cache=none$'
|
|
exec devvm mount-cache
|
|
stdout '\Ammap\n\z'
|
|
stderr '^mount_cache_pending mode=none vm=devvm-web-[0-9a-f]{14}$'
|
|
exec devvm mount-cache --json
|
|
stdout '"pending": "none"'
|
|
exec devvm
|
|
stderr '^devvm: next_start_mount_cache vm=devvm-web-[0-9a-f]{14}$'
|
|
! stderr mount_cache_unchosen
|
|
|
|
# Stopped: the next start sets it in its one edit, then mounts the folder
|
|
# again and checks it; the start after that edits nothing.
|
|
exec limactl stop $WEB
|
|
stub_reset
|
|
exec devvm
|
|
stub_calls
|
|
stdout '^limactl edit --tty=false devvm-web-[0-9a-f]{14} --set \.mounts = \[\{"location":"\S*/web","writable":true,"9p":\{"cache":"none"\}\},'
|
|
! stdout '(?s)limactl edit --tty=false devvm-web.*limactl edit --tty=false devvm-web'
|
|
stdout '^limactl start --tty=false devvm-web-[0-9a-f]{14}\n(.*\n)*limactl shell --workdir / devvm-web-[0-9a-f]{14} sudo sh -c umount ''\S*/web'' \|\| exit 3; mount '
|
|
stdout '^limactl shell --workdir / devvm-web-[0-9a-f]{14} sh -c if mountpoint -q ''\S*/web''; then P=''\S*/web'' awk .* /proc/self/mountinfo; '
|
|
exec devvm mount-cache
|
|
stdout '\Anone\n\z'
|
|
! stderr .
|
|
exec limactl stop $WEB
|
|
stub_reset
|
|
exec devvm
|
|
stub_calls
|
|
! stdout 'limactl edit'
|
|
|
|
# A folder that isn't mounted after the remount gets one restart, whose
|
|
# boot mounts it. One that isn't mounted after the restart either fails
|
|
# the launch before its shell opens, naming devvm restart.
|
|
exec limactl stop $WEB
|
|
json_set $WEB_dir/vm.json mount:={}
|
|
exec sh -c 'limactl edit "$1" --set ".mounts = [{\"location\":\"$(pwd -P)\",\"writable\":true},{\"location\":\"$DATA/tools\",\"mountPoint\":\"/mnt/devvm-tools\",\"writable\":false}]"' sh $WEB
|
|
exec devvm mount-cache none
|
|
stdout '^==> mount_cache_pending mode=none vm=devvm-web-[0-9a-f]{14}$'
|
|
exec sh -c ': > "$STUB_DIR/mount-unmounted"'
|
|
stub_reset
|
|
! exec devvm
|
|
stderr '^devvm: mount_cache_unmounted vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout '^limactl shell --workdir \S*/web devvm-web'
|
|
stdout '(?s)sudo sh -c umount .*\nlimactl stop devvm-web-[0-9a-f]{14}\n(.*\n)*limactl start --tty=false devvm-web-[0-9a-f]{14}\n(.*\n)*limactl stop devvm-web-[0-9a-f]{14}\n'
|
|
! stdout '(?s)sudo sh -c umount .*sudo sh -c umount '
|
|
! stdout '(?s)(limactl start --tty=false devvm-web.*){3}'
|
|
rm $STUB_DIR/mount-unmounted
|
|
|
|
# The remount fails, as an Alpine guest's can, and leaves the folder
|
|
# unmounted: the restart's boot mounts it with none, and the launch goes
|
|
# on into its shell, with the restart in the run log. The restart is a
|
|
# whole start again, on the allowlist tier a proxy of its own, which
|
|
# warns of a policy line that isn't a rule once, not at each start.
|
|
exec limactl stop $WEB
|
|
json_set $WEB_dir/vm.json mount:={}
|
|
exec sh -c 'limactl edit "$1" --set ".mounts = [{\"location\":\"$(pwd -P)\",\"writable\":true},{\"location\":\"$DATA/tools\",\"mountPoint\":\"/mnt/devvm-tools\",\"writable\":false}]"' sh $WEB
|
|
exec devvm mount-cache none
|
|
exec devvm network allowlist
|
|
exec sh -c 'echo "example.com:x" >> "$CFG/policy"'
|
|
exec sh -c ': > "$STUB_DIR/remount-fails"'
|
|
stub_reset
|
|
exec devvm
|
|
! stderr 'mount_cache_'
|
|
stderr -count=1 '^devvm: policy_not_rule file=\S*/policy line=\d+ rule=example\.com:x$'
|
|
exec sh -c 'grep -v "example.com:x" "$CFG/policy" > "$WORK/p"; cat "$WORK/p" > "$CFG/policy"'
|
|
stub_calls
|
|
stdout '(?s)sudo sh -c umount .*\nlimactl stop devvm-web-[0-9a-f]{14}\n(.*\n)*limactl start --tty=false devvm-web-[0-9a-f]{14}\n(.*\n)*limactl shell --workdir \S*/web devvm-web-[0-9a-f]{14}\n'
|
|
! stdout '(?s)sudo sh -c umount .*sudo sh -c umount '
|
|
exec sh -c 'cat "$DATA"/logs/runs/*.log'
|
|
stdout 'devvm: devvm-web-[0-9a-f]{14}''s project folder after its remount: it isn''t mounted; restarting the VM$'
|
|
exec devvm mount-cache
|
|
stdout '\Anone\n\z'
|
|
rm $STUB_DIR/remount-fails
|
|
exec devvm stop
|
|
exec devvm network open
|
|
|
|
# A launch into a running VM whose folder isn't mounted is refused before
|
|
# its shell.
|
|
exec devvm
|
|
exec sh -c ': > "$STUB_DIR/mount-unmounted"'
|
|
stub_reset
|
|
! exec devvm
|
|
stderr '^devvm: project_unmounted vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout '^limactl shell --workdir \S*/web devvm-web'
|
|
rm $STUB_DIR/mount-unmounted
|
|
|
|
# A stored mmap, as a build of devvm before none alone wrote, is none
|
|
# chosen: the VM works, warns, and devvm mount-cache none switches it.
|
|
exec limactl stop $WEB
|
|
json_set $WEB_dir/vm.json mount.cache=mmap
|
|
exec sh -c 'limactl edit "$1" --set ".mounts = [{\"location\":\"$(pwd -P)\",\"writable\":true},{\"location\":\"$DATA/tools\",\"mountPoint\":\"/mnt/devvm-tools\",\"writable\":false}]"' sh $WEB
|
|
exec devvm mount-cache
|
|
stdout '\Ammap\n\z'
|
|
stderr '^devvm: mount_cache_unchosen mode=mmap '
|
|
exec devvm mount-cache none
|
|
stdout '^==> mount_cache_pending mode=none '
|
|
|
|
# A state with a mode devvm doesn't know is refused as the VM is found,
|
|
# naming its state file.
|
|
json_set $WEB_dir/vm.json mount.cache=loose
|
|
! exec devvm mount-cache
|
|
stderr '\S*/vm\.json: mount\.cache: mount_cache_invalid value="loose"'
|
|
|
|
# A VM an earlier devvm left strict, with no cache mode chosen, on a host
|
|
# that pins (DEVVM_PINS), as on is refused where it can't (git_pins.txtar):
|
|
# after devvm mount-cache none, one start converts strict to on and
|
|
# switches the cache in its one edit, then mounts the folder again.
|
|
env DEVVM_PINS=on
|
|
project app git
|
|
exec devvm --network open
|
|
vm_name APP app
|
|
exec devvm stop
|
|
json_set $APP_dir/vm.json mount:={} git.mode=strict
|
|
exec sh -c 'limactl edit "$1" --set ".mounts = [{\"location\":\"$(pwd -P)\",\"writable\":true},{\"location\":\"$DATA/tools\",\"mountPoint\":\"/mnt/devvm-tools\",\"writable\":false}]"' sh $APP
|
|
exec git config --file .git/config diff.ignoreSubmodules all
|
|
exec devvm mount-cache none
|
|
stdout '^==> mount_cache_pending mode=none vm=devvm-app-[0-9a-f]{14}$'
|
|
stub_reset
|
|
exec devvm
|
|
stderr '^devvm: git_strict_converted vm=devvm-app-[0-9a-f]{14}$'
|
|
! stderr 'mount_cache_unchosen|mount_cache_unchecked|mount_cache_unmounted'
|
|
stub_calls
|
|
stdout '^limactl edit --tty=false devvm-app-[0-9a-f]{14} --set \.mounts = \[\{"location":"\S*/app","writable":true,"9p":\{"cache":"none"\}\},'
|
|
! stdout '(?s)limactl edit --tty=false devvm-app.*limactl edit --tty=false devvm-app'
|
|
stdout '^limactl start --tty=false devvm-app-[0-9a-f]{14}\n(.*\n)*limactl shell --workdir / devvm-app-[0-9a-f]{14} sudo sh -c umount ''\S*/app'' \|\| exit 3; mount '
|
|
vm_state $APP_dir/vm.json
|
|
stdout '^git\.mode=on$'
|
|
stdout '^mount\.cache=none$'
|
|
|
|
-- features-none.json --
|
|
{"features": []}
|