mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
A VM that devvm 0.1.0 started and that runs as you upgrade keeps what 0.1.0 gave it until its next start. Two of those went unsaid: - A launch into a running VM whose start forwarded an SSH agent itself (an older devvm's recorded start, without made.relayed) keeps that agent, which can add, remove or lock keys, and now warns, naming devvm restart, which gives it the relay (agent_raw_old). - devvm doctor said nothing of a running proxy without run/proxy.confined. One that another devvm binary started (its config's devvm_sha256) is an older devvm's single process without a sandbox, which it now names (proxy_old); one this binary started that hasn't written the file yet is still starting and gets none. doctor now passes devvm's own binary to the check. Tests, on 0.1.0's frozen state made running in the sandbox copy (hostagent pid file at 0.1.0's start's time from its known_hosts, run/ started, known_hosts and agent.made.started for that start, Lima listing it running, its ssh port listened on, and 0.1.0's one-process proxy): fixture_v010_running.txtar (doctor's proxy_old; a launch with no stop, start or edit, ports_ssh_old, the proxy started again as broker and child with proxy.confined, secrets.json and known_hosts unchanged, no relayed; then stop and launch: one .ssh.localPort edit, the new start's keys pinned) and fixture_v010_running_agent.txtar (devvm's agent forwarded raw: kept and warned, then devvm restart gives the relay and relayed, with only the ssh port's edit). The modelled hostagent is a live process of the test's, not 0.1.0's pid 54798, because a start counts as devvm's only while its hostagent runs. TestUnconfined: a proxy that hasn't said, by this binary, another, or an unreadable config. - msg: agent_raw_old, proxy_old. - Docs: ssh (agent forwarding), troubleshooting (the proxy runs without a sandbox), internals/install; CHANGELOG After you upgrade. Co-Authored-By: Claude Opus 5.5 <[email protected]>
109 lines
4.5 KiB
Plaintext
109 lines
4.5 KiB
Plaintext
# devvm 0.1.0's app VM (testdata/v0.1.0/GOOS: see fixture_v010.txtar),
|
|
# running as 0.1.0 left it when you upgrade (running.sh): Lima lists it
|
|
# as running, on 0.1.0's start of it, with 0.1.0's proxy, one process,
|
|
# which devvm doctor names. A launch goes into it as it runs: no stop,
|
|
# start or edit, its ssh port warned of, its proxy started again as two
|
|
# processes, sandboxed, the bindings file and host keys as they were, and
|
|
# no relay recorded. Its next start moves the ssh port, in one edit, and
|
|
# pins the new start's keys.
|
|
[!darwin] [!linux] skip 'a fixture for macOS and Linux only'
|
|
env GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@t GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@t
|
|
mkdir $HOME/src/db $HOME/src/app $HOME/src/web $HOME/src/scratch
|
|
cd $HOME/src/app
|
|
exec git init -q -b main
|
|
exec git commit -q --allow-empty -m one
|
|
fixture v0.1.0
|
|
vm_name APP app
|
|
|
|
# 0.1.0's start of app, still running, and its proxy. Its hostagent
|
|
# listens on its ssh port, which 0.1.0 chose from the whole range: here
|
|
# one of the sandbox's that something listens on, in its state and its
|
|
# Lima config alike.
|
|
listen_any SSH
|
|
json_set $APP_dir/vm.json ports.host.ssh:=$SSH
|
|
exec limactl edit --tty=false $APP --set .ssh.localPort=$SSH
|
|
cd $WORK
|
|
exec sh hostagent &hostagent&
|
|
wait_file $WORK/hostagent.pid
|
|
exec sh running.sh $APP $APP_dir off
|
|
exec sh _proxy -config $APP_dir/run/proxy.json &oldproxy&
|
|
wait_file $WORK/oldproxy.up
|
|
cd $HOME/src/app
|
|
exec devvm doctor
|
|
stderr '^devvm: proxy_old vm=devvm-app-[0-9a-f]{14}$'
|
|
|
|
cp $APP_dir/run/secrets.json $WORK/app-secrets.json
|
|
cp $APP_dir/run/known_hosts $WORK/app-known_hosts
|
|
cp $APP_dir/run/proxy.pid $WORK/old.pid
|
|
stub_reset
|
|
exec devvm
|
|
! stdout starting
|
|
stderr '^devvm: ports_ssh_old vms=devvm-app-[0-9a-f]{14}$'
|
|
! stderr 'unreadable|corrupt|layout_|replaced|refused|failed|unenforced|agent_raw_old'
|
|
stub_calls
|
|
! stdout 'limactl (stop|start|edit|create|clone|delete)'
|
|
# Its proxy runs again as broker and child, sandboxed as this host
|
|
# allows, and 0.1.0's is gone.
|
|
! cmp $APP_dir/run/proxy.pid $WORK/old.pid
|
|
exists $APP_dir/run/proxy-child.pid
|
|
exists $APP_dir/run/proxy.confined
|
|
exec sh -c '! kill -0 "$(cat "$WORK/old.pid")" 2>/dev/null'
|
|
cmp $APP_dir/run/secrets.json $WORK/app-secrets.json
|
|
cmp $APP_dir/run/known_hosts $WORK/app-known_hosts
|
|
vm_state $APP_dir/vm.json
|
|
! stdout '^agent\.made\.relayed='
|
|
exec devvm doctor
|
|
! stderr proxy_old
|
|
|
|
# Its next start moves its ssh port, in that one edit, and pins the new
|
|
# start's keys.
|
|
exec devvm stop
|
|
stub_reset
|
|
exec devvm
|
|
stdout '^==> starting what=devvm-app-[0-9a-f]{14}$'
|
|
! stderr ports_ssh_old
|
|
stub_calls
|
|
stdout '^limactl edit --tty=false devvm-app-[0-9a-f]{14} --set \.ssh\.localPort=[0-9]+$'
|
|
! stdout '(?s)limactl edit .*limactl edit'
|
|
! cmp $APP_dir/run/known_hosts $WORK/app-known_hosts
|
|
grep '^devvm-app-[0-9a-f]{14} ssh-ed25519 ' $APP_dir/run/known_hosts
|
|
exec devvm stop
|
|
|
|
-- hostagent --
|
|
# A hostagent of 0.1.0's start, which runs until the test ends: a VM's
|
|
# start counts as devvm's, confined, only while its hostagent runs. It
|
|
# ends on the interrupt the test's end sends.
|
|
trap 'exit 0' INT TERM
|
|
echo $$ >"$WORK/hostagent.pid.new" && mv "$WORK/hostagent.pid.new" "$WORK/hostagent.pid"
|
|
while :; do sleep 1; done
|
|
-- running.sh --
|
|
# running.sh VM DIR MODE: VM, whose state is in DIR, runs on 0.1.0's
|
|
# start of it, as 0.1.0 recorded it, but for its hostagent's pid, which
|
|
# is hostagent's here, as the start's must run (0.1.0's own, 54798 in
|
|
# the darwin fixture, is long gone): Lima's pid file holds it, written at
|
|
# the time 0.1.0's start was (its known_hosts' start line), the start's
|
|
# record (run/started) names it, confined, its known_hosts names the
|
|
# start, and its agent section's start is that start's hash, with MODE,
|
|
# the agent's choice it started with. Lima lists it as running.
|
|
set -e
|
|
read -r _ _ _ _ _ _ _ at <"$2/run/known_hosts"
|
|
pid=$(cat "$WORK/hostagent.pid")
|
|
test -n "$pid" && test -n "$at"
|
|
echo "$pid" >"$LIMA_HOME/$1/ha.pid"
|
|
touch -d "$at" "$LIMA_HOME/$1/ha.pid"
|
|
echo "$pid 1" >"$2/run/started"
|
|
sed -i.bak "1s/.*/# devvm: host keys of start $pid $at/" "$2/run/known_hosts"
|
|
h=$(printf %s "$pid $at" | { sha256sum 2>/dev/null || shasum -a 256; } | cut -c1-32)
|
|
sed -i.bak "s/\"started\": \"[a-z]*_[0-9a-f]*\"/\"started\": \"${3}_$h\"/" "$2/vm.json"
|
|
rm -f "$2/run/known_hosts.bak" "$2/vm.json.bak"
|
|
stub vm "$1" Running
|
|
-- _proxy --
|
|
# 0.1.0's proxy, as devvm finds it: devvm _proxy -config with the VM's
|
|
# config, its pid in the VM's proxy.pid. One process, which writes no
|
|
# child's pid and no confinement.
|
|
trap 'exit 0' INT TERM
|
|
dir=$(dirname "$2")
|
|
echo $$ >"$dir/proxy.pid"
|
|
touch "$WORK/oldproxy.up"
|
|
while :; do sleep 1; done
|