Files
devvm/testdata/script/fixture_v010_running_agent.txtar
w3cjandClaude Opus 5.5 93322e9154 fix(vm): running 0.1.0 VMs are warned of and tested
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]>
2026-11-18 19:59:14 -07:00

82 lines
3.1 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, as in
# fixture_v010_running.txtar, but forwarding devvm's own SSH agent as
# 0.1.0 forwarded one: its choice devvm, its start recorded with that
# choice and no relay, and Lima forwarding the agent itself. A launch
# keeps the agent as 0.1.0 forwarded it, so the VM goes on working, and
# warns that devvm restart gives it the relay, which it does, in the
# start's one edit, the ssh port's.
[!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 with devvm's agent, still running.
json_set $APP_dir/vm.json agent.mode=devvm
exec limactl edit --tty=false $APP --set .ssh.forwardAgent=true
cd $WORK
exec sh hostagent &hostagent&
wait_file $WORK/hostagent.pid
exec sh running.sh $APP $APP_dir devvm
cd $HOME/src/app
vm_state $APP_dir/vm.json
stdout '^agent\.made\.started=devvm_[0-9a-f]{32}$'
! stdout '^agent\.made\.relayed='
stub_reset
exec devvm
! stdout starting
stderr '^devvm: agent_raw_old vm=devvm-app-[0-9a-f]{14}$'
! stderr 'unreadable|corrupt|layout_|replaced|refused|failed|unenforced'
stub_calls
! stdout 'limactl (stop|start|edit)'
vm_state $APP_dir/vm.json
! stdout '^agent\.made\.relayed='
# devvm restart gives it the relay, with no edit but its ssh port's.
# (Its new start's hostagent: hostagent's, which lasts.)
cp $WORK/hostagent.pid $STUB_DIR/hostagent
stub_reset
exec devvm restart
! stderr agent_raw_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'
vm_state $APP_dir/vm.json
stdout '^agent\.made\.relayed=true$'
stdout '^agent\.made\.started=devvm_[0-9a-f]{32}$'
stub_reset
exec devvm
! stderr agent_raw_old
stub_calls
! stdout 'limactl (stop|start|edit)'
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 fixture_v010_running.txtar's running.sh has it, its
# agent section's start recorded with MODE.
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