mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
Lima's download of the cloud image neither retries nor times out: one cut in its 900 MB fails base's build, and a stall hangs it. devvm now downloads the pinned image itself through fetch.Resumable (ubuntu.Download), into images/ubuntu/<sha256>.img (Dirs.UbuntuImage), resuming across cuts, stalls and runs, and gives Lima that file. Lima 2.3 checks a local file against the digest before it copies it. - Before downloading, it takes the image from Lima's own download cache when that holds it with the pin's SHA-256: copied into a new file of devvm's own, mode 600, hashed as it's written, capped, stopped by the context, and kept only once it checks out. Lima's cache is never changed, and a base whose dated release Ubuntu may have removed still builds again. - One devvm downloads at a time (images/locks/ubuntu-image), another waiting under ubuntu_image_waiting and looking again under the lock (TestUbuntuImageAfterWait, which fails without that second look). - The download goes through the company proxy and trusts the user's CAs (Lima.Roots, from trust.Pool, which internal/cli passes through the registry), as do the Finder's lookups (TestNewTrustsRoots, and the registry's TestOverrides). An untrusted certificate is ubuntu_untrusted, naming the CAs' folder, one from a trusted CA that's for another host, out of date or not valid yet ubuntu_bad_certificate (check the clock and what answers for the host), and any other that fails to verify (a SHA-1 signature, a CA's name constraints, a key for clients alone) ubuntu_certificate_invalid, naming Go's reason, for the lookups (the listing, the checksums, their signature: TestLookupCertificates) and the download alike (TestLocalImageFailsFor), and a release Ubuntu removed (404, 410) ubuntu_release_gone, which names devvm rebuild base; none is retried. ubuntu_download_failed no longer starts with devvm. - fetch.Untrusted, fetch.BadCertificate (an x509.HostnameError, or a CertificateInvalidError that's Expired) and fetch.Unverified (any failure to verify, with its reason, so every error the other two name), beside fetch.Gone, are the one place that tells a certificate's failures apart: Transient asks Unverified, the lookups and the download ask all three, host mise asks Untrusted, and a forbidigo rule keeps x509's and tls's verification errors in internal/fetch (TestCertificateClasses, TestTransient, testdata/lint, the owners doc's row). - An https address, or a test build's file:// DEVVM_UBUNTU_URL, read from disk the same way; anything else is refused. The CLI tests' sandbox has a stand-in of this host's image in the store. - Base's record keeps the image's address, and the key is as it was: it hashes the pin (release, file, digest), not the location. - devvm gc --caches frees devvm's copies that no record names and that aren't pinned now, unchanged for an hour, a stopped .part and a killed import's .import included, and those of a kept image once its .img is there. A pin it can't read fails it. - Of Lima's cache, it frees only an entry that devvm's own state shows a build of devvm's left: a base record names its address, devvm has its own copy of the image, and the installed Lima's own templates (share/lima/templates beside limactl, Lima.Templates) don't name it. An entry no record names may be the user's own Lima's, so it stays, and none is freed when the templates can't be read, with a line in the run log naming the folder and why. A test build's DEVVM_LIMA_TEMPLATES stands in for the templates folder. - ubuntu.ParseImage reads a record's image as Image.String writes it, and ubuntu.IsSHA256 is the one check of a cloud image's SHA-256, in place of Lima's own regex. - devvm space shows the copies as a cloud images row, freed by gc --caches, kept as state, as a release Ubuntu removed can't be downloaded again. 0.1.0's frozen state runs the new commands (fixture_v010_cloud_image): devvm looks in Lima's cache under the SHA-256 of the address 0.1.0's base record keeps and never changes the entry, base builds from devvm's own copy, and gc --caches keeps that copy, frees Lima's entry the record names and devvm's own stale copies, and keeps an older entry no record names. Docs: images.md (the download, its failures, the import, gc's rules), space.md, backends/lima.md, settings.md (the lookups and the download trust your CAs), troubleshooting.md, overview.md, testing.md, tests.md, structure.md's internal/fetch row; the CHANGELOG's two Fixed lines, which later commits make highlights, What to do 5 and 6, and the release page's Ubuntu's cloud image in devvm's folder. New messages: downloading_ubuntu, importing_ubuntu, ubuntu_image_waiting, ubuntu_download_failed, ubuntu_release_gone, ubuntu_bad_certificate, ubuntu_certificate_invalid, ubuntu_image_checksum, ubuntu_untrusted. Lima.LocalImage is the seam, Lima.ImageClient the client. Co-Authored-By: Claude Opus 5.5 <[email protected]>
119 lines
6.1 KiB
Plaintext
119 lines
6.1 KiB
Plaintext
# space: each kind of thing devvm keeps, with its count, size, whether
|
|
# devvm makes it again, what gc frees of it now and what frees the rest,
|
|
# then a total; Lima's caches apart. It changes nothing: no Lima command
|
|
# but listings.
|
|
env SHARE=$XDG_DATA_HOME/devvm/tools
|
|
|
|
# Nothing yet: devvm's state and the total.
|
|
exec devvm space
|
|
stdout '^WHAT +COUNT +SIZE +KEPT +GC +FREED BY +RETAIN\n'
|
|
stdout '^state +1 +\S+ +state +- +- +-\n'
|
|
stdout '^total +- +\S+ +- +- +- +-\n'
|
|
! stdout '^images'
|
|
! stderr .
|
|
|
|
# base and foo, then foo is stale; claude's tools, current, an old go a VM
|
|
# has and one nothing has; a Lima VM, and the state of one Lima no longer
|
|
# has; an export, network and run logs.
|
|
mkdir $XDG_CONFIG_HOME/devvm/layers
|
|
cp foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh
|
|
exec devvm build foo
|
|
project ag
|
|
exec devvm --tools none --agents claude --network open --no-git-protect
|
|
exec devvm rm --force --no-export
|
|
exec sh -c 'echo "# edited" >> "$XDG_CONFIG_HOME/devvm/layers/foo.sh"'
|
|
exec sh -c 'cd "$SHARE" && echo x > go-1.20.0-0123456789ab.erofs && echo x > go-1.9.0-0123456789ab.erofs'
|
|
json_set $SHARE/go-1.20.0-0123456789ab.erofs.json sha256=x libc=gnu backend=lima built=2020-01-01T00:00:00Z
|
|
mkdir $VMS/12345612345601/logs $VMS/12345612345602/logs
|
|
json_set $VMS/12345612345601/vm.json version:=1 id=p name=devvm-p-12345612345601 image=base dir=/p backend=lima created=2020-01-01T00:00:00Z tools.names:=["go"] tools.made.libc=gnu tools.made.files:=["go-1.20.0-0123456789ab.erofs"]
|
|
# The one Lima no longer has was made in this run's Lima home, its state
|
|
# unchanged for over an hour: what devvm gc --orphans would forget.
|
|
exec sh -c 'printf %s "$DEVVM_LIMA_HOME" | { sha256sum 2>/dev/null || shasum -a 256; } | cut -c1-16 > at'
|
|
exec sh -c 'printf "{\"version\": 1, \"id\": \"gone\", \"name\": \"devvm-gone-12345612345602\", \"image\": \"base\", \"dir\": \"/q\", \"backend\": \"lima\", \"backend_at\": \"%s\", \"created\": \"2020-01-01T00:00:00Z\", \"tools\": {\"names\": [\"go\"], \"made\": {\"libc\": \"gnu\"}}}\n" "$(cat at)" > "$VMS/12345612345602/vm.json" && touch -t 202001010000 "$VMS/12345612345602/vm.json"'
|
|
exec stub vm devvm-p-12345612345601 Stopped
|
|
mkdir $DATA/exports $DATA/logs $DATA/cache/mise/2026.1.1
|
|
exec sh -c 'echo x > "$DATA/exports/devvm-old-12345612345612-20260101-000000.tar.gz"'
|
|
# The VM's network and proxy logs are network logs; the gone one's are
|
|
# part of its leftover state.
|
|
exec sh -c 'echo x > "$VMS/12345612345601/logs/network.jsonl" && echo x > "$VMS/12345612345601/logs/proxy.log" && echo x > "$VMS/12345612345602/logs/proxy.log"'
|
|
stub_reset
|
|
exec devvm space
|
|
stdout '^VMs +1 +\S+ +only copy +- +devvm rm +-$'
|
|
stdout '^images +2 +\S+ +remade +\S+ +images rm +-$'
|
|
stdout '^tools gnu +\d+ +\S+ +remade +- +gc --tool-images +-$'
|
|
stdout '^tools - +1 +\S+ +remade +\S+ +gc --tool-images +-$'
|
|
stdout '^history +1 +\S+ +only copy +- +gc --history +-$'
|
|
stdout '^network logs +2 +\S+ +log +- +devvm rm +-$'
|
|
stdout '^run logs +\d+ +\S+ +log +- +the newest 20 stay +-$'
|
|
stdout '^mise +1 +'
|
|
# Ubuntu's cloud image base was made from, devvm's own copy: freed by gc
|
|
# --caches once nothing needs it, never counted as state.
|
|
stdout '^cloud images +1 +\S+ +state +- +gc --caches +-$'
|
|
stdout '^leftover state +1 +\S+ +leftover +- +gc --orphans +-$'
|
|
stdout '^total +- +\S+ +- +\S+ +- +-$'
|
|
! stdout '^devvm.s files'
|
|
# The VM's folder, /p, is gone: named, while the one Lima lost isn't.
|
|
stderr '\Aspace_folder_gone dir=/p vm=devvm-p-12345612345601\n\z'
|
|
stub_calls
|
|
! stdout 'create|clone|delete|start|stop|edit|rm |prune|shell'
|
|
|
|
# Leftover state is only what devvm gc --orphans would forget: never a VM
|
|
# Lima no longer has whose state changed in the last hour (it may be being
|
|
# made), nor one made in another Lima home.
|
|
mkdir $VMS/12345612345604 $VMS/12345612345605
|
|
exec sh -c 'printf "{\"version\": 1, \"id\": \"new\", \"name\": \"devvm-new-12345612345604\", \"image\": \"base\", \"dir\": \"/n\", \"backend\": \"lima\", \"backend_at\": \"%s\", \"created\": \"2020-01-01T00:00:00Z\"}\n" "$(cat at)" > "$VMS/12345612345604/vm.json"'
|
|
json_set $VMS/12345612345605/vm.json version:=1 id=moved name=devvm-moved-12345612345605 image=base dir=/m backend=lima backend_at=0000000000000000 created=2020-01-01T00:00:00Z
|
|
exec touch -t 202001010000 $VMS/12345612345605/vm.json
|
|
exec devvm space
|
|
stdout '^leftover state +1 +\S+ +leftover +- +gc --orphans +-$'
|
|
# gc lists the same one, and without a terminal or --force deletes nothing.
|
|
! exec devvm gc --orphans
|
|
stdout '^gc_orphans count=1$'
|
|
stdout '^gc_orphan backend=lima dir=/q vm=devvm-gone-12345612345602$'
|
|
stderr '^devvm: no_input answer=--force$'
|
|
stderr '^gc_orphan_recent vm=devvm-new-12345612345604$'
|
|
stderr '^gc_orphan_elsewhere vm=devvm-moved-12345612345605$'
|
|
rm $VMS/12345612345604 $VMS/12345612345605
|
|
|
|
# --backend is no flag of space's.
|
|
! exec devvm space --backend lima
|
|
stderr '^devvm: flag_unknown command=devvm space flag=--backend$'
|
|
|
|
# --json, for scripts.
|
|
exec devvm space --json
|
|
stdout '^{\n "version": 1,\n "devvm": \[\n'
|
|
stdout '"what": "leftover state"'
|
|
stdout '"kept": "only copy"'
|
|
stdout '"total": \d+'
|
|
|
|
# A backend a VM's state names that doesn't answer is named, and its VMs
|
|
# are never leftovers.
|
|
mkdir $VMS/12345612345603
|
|
json_set $VMS/12345612345603/vm.json version:=1 id=s name=devvm-s-12345612345603 image=base dir=/s backend=lima created=2020-01-01T00:00:00Z
|
|
exec sh -c 'touch "$STUB_DIR/list-fails"'
|
|
exec devvm space
|
|
stderr '^space_backend_unknown backend=lima$'
|
|
! stdout '^leftover state '
|
|
|
|
# A backend slower than the timeout is named the same way, and its VMs
|
|
# aren't leftovers either.
|
|
rm $STUB_DIR/list-fails
|
|
exec sh -c 'touch "$STUB_DIR/list-hangs"'
|
|
env DEVVM_TEST_LIST_TIMEOUT=10m,lima:1s
|
|
exec devvm space
|
|
stderr '^space_backend_unknown backend=lima$'
|
|
! stdout '^leftover state '
|
|
rm $STUB_DIR/list-hangs
|
|
env DEVVM_TEST_LIST_TIMEOUT=10m
|
|
|
|
# Lima's download cache, which every Lima home shares: shown apart.
|
|
[darwin] mkdir $HOME/Library/Caches/lima/download/by-url-sha256/0123
|
|
[darwin] exec sh -c 'echo x > "$HOME/Library/Caches/lima/download/by-url-sha256/0123/data"'
|
|
[darwin] exec devvm space
|
|
[darwin] stdout '^CACHE +COUNT +SIZE +PATH\ndownload cache +1 +\S+ +\S+/Library/Caches/lima\n'
|
|
[darwin] stderr '^space_caches_note$'
|
|
|
|
-- foo.sh --
|
|
#!/bin/bash
|
|
echo foo
|