Skip to content

Fix: pull the sandbox image on every run, in both VM paths - #665

Merged
cwiklik merged 1 commit into
rossoctl:mainfrom
cwiklik:fix/414-vm-sandbox-image-pull
Oct 29, 2026
Merged

cwiklik merged 1 commit into
rossoctl:mainfrom
cwiklik:fix/414-vm-sandbox-image-pull

Conversation

@cwiklik

@cwiklik cwiklik commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Summary

podman run resolves an image reference only when the host has no copy of it, so a mutable
:latest pulled once is never re-resolved — every later setup-vm.sh run starts the sandboxes on
it. On the 2026-10-01 KVM rig that copy predated #372: HOME was the shared /workspace rather
than /home/sandbox, and nothing in the bring-up's output hinted the containers were not what
main builds.

deploy/microvm/build-rootfs.sh had the same bug in a worse place: podman image exists || podman pull pulled only on a host with no copy, and a snapshot is built once and run for a long time, so
a stale rootfs outlived the image it was meant to track.

Both now pull before use, fail closed on a failed pull, and take SH_SKIP_PULL=1 as the documented
override for an offline host or a locally built image — the convention #349 established for
deploy/compose/install.sh.

Two details that are load-bearing rather than incidental:

  • Ordering. setup-vm.sh pulls before start_sandboxes, because podman run --replace
    recreates each container from whatever the reference resolves to at that moment. A pull after it
    would leave this run's sandboxes on the old image and only benefit the next run. There is a
    main() assertion for this.
  • The id, not the tag. Both scripts log the resolved image id and creation time: :latest is
    the same string on a current and a pre-feat: per-user inference credential headers and sandbox research tooling (#368 phase 1) #372 host, so the id is what answers "is this host on the
    current image?".
==> pulling ghcr.io/rossoctl/moca-remote-worker:latest
==> sandbox image ghcr.io/rossoctl/moca-remote-worker:latest is 102ed4c1cfb9, created 2026-10-01T…

An image with no local copy warns instead of aborting — refusing there would be refusing over the
script's own reporting step, and podman run will pull.

Changes

File Change
deploy/vm/setup-vm.sh new pull_sandbox_image (fail-closed, SH_SKIP_PULL) and describe_sandbox_image; called from main() before start_sandboxes
deploy/vm/tests/setup-vm.test.sh podman image inspect mock branch; four cases (pull happens, failed pull refuses, skip path, uninspectable image warns) + main() ordering assertion
deploy/microvm/build-rootfs.sh podman image exists || podman pull replaced by an unconditional fail-closed pull with SH_SKIP_PULL
deploy/microvm/tests/build-rootfs.test.sh image re-resolved every build (the image exists short-circuit is gone, not reordered), failed pull refuses before export, skip path + no-local-copy refusal
deploy/vm/README.md new "The sandbox image is pulled on every run" section; step 7 and the SANDBOX_IMAGE paragraph updated
docs/reference/configuration.md SH_SKIP_PULL promoted to its own bullet, naming all three scripts
docs/demos/vm-multi-user-demo.md 0a's manual-pull workaround replaced by reading the logged image line; fix-list row 4 → Fixed
deploy/microvm/P4-ON-P6.md per-run pull rationale and SH_SKIP_PULL

Testing

Check Result
deploy/vm/tests/setup-vm.test.sh EXIT:0, 101 oks (baseline 97)
deploy/microvm/tests/build-rootfs.test.sh EXIT:0, 36 oks
4 negative tests — no pull_sandbox_image; pull moved after start_sandboxes; pull made non-fatal; pristine build-rootfs.sh each fails with the intended message
make test-deploy 30/31 suites pass. Sole failure is build-snapshot.test.sh, which produces the identical two assertions and exit 2 on stashed HEAD — pre-existing, needs microVM build tooling on this Mac
make test-deploy-bash32 clean, 56 oks, 0 failures (bash 3.2.57)
build-rootfs.test.sh under /bin/bash 3.2 EXIT:0, 36 oks
shellcheck -x -S warning, pre-commit shellcheck + secrets pass
prettier, scripts/check-doc-links.py clean; 212 files, 0 broken links

setup-vm.test.sh cannot run under bash 3.2 — mapfile at deploy/vm/tests/setup-vm.test.sh:340
predates this PR, which is why make test-deploy-bash32 does not list that suite. Not a regression
here, but worth a follow-up.

No new feature, so CLAUDE.md's feature-flag rule does not apply: this is a bug fix in deployment
tooling, behind no user-facing switch.

Fixes #414

Assisted-By: Claude Code

`podman run` resolves an image reference only when the host has no copy of
it, so a mutable `:latest` pulled once is never re-resolved -- every later
`setup-vm.sh` run starts the sandboxes on it. On the 2026-10-01 KVM rig that
copy predated rossoctl#372: HOME was the shared /workspace rather than /home/sandbox,
and nothing in the bring-up's output hinted the containers were not what main
builds. `build-rootfs.sh` had the same bug in a worse place: `podman image
exists || podman pull` pulled only on a host with no copy, and a snapshot is
built once and run for a long time, so a stale rootfs outlived the image it
was meant to track.

Both now pull before use, fail closed on a failed pull, and take
SH_SKIP_PULL=1 as the documented override for an offline host or a locally
built image -- the convention rossoctl#349 established for `deploy/compose/install.sh`.
setup-vm.sh pulls before start_sandboxes, because `podman run --replace`
recreates each container from whatever the reference resolves to at that
moment. Both also log the resolved image id and creation time rather than the
tag asked for: `:latest` is the same string on a current and a pre-rossoctl#372 host,
so the id is what answers "is this host on the current image?".

Tests: setup-vm.test.sh gains the pull, the fail-closed refusal, the skip path
and an uninspectable image warning, plus a main() ordering assertion that the
pull precedes the first container; build-rootfs.test.sh asserts the image is
re-resolved every build (and that the `image exists` short-circuit is gone,
not merely reordered), that a failed pull refuses before exporting, and that
SH_SKIP_PULL builds from the local copy but refuses when there is none.

Fixes rossoctl#414

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
@cwiklik
cwiklik requested a review from pdettori as a code owner October 29, 2026 18:11
@cwiklik cwiklik added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 29, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — the fix is correct and well-ordered: pull_sandbox_image runs after the firewall and before start_sandboxes, a failed pull aborts main() under set -euo pipefail, the build-rootfs.sh image exists || short-circuit is removed (not reordered), and SH_SKIP_PULL matches #349's compose convention. The main() ordering assertion is a good guard. CI is green on this head.

Two follow-ups inline:

  • Stale "setup-vm.sh never pulls" guidance outside the diff. deploy/microvm/P4-ON-P6.md:38-44 still says setup-vm.sh never pulls and tells operators to podman pull by hand first. deploy/microvm/setup-microvm.sh:206 (comment) and its check_container_tiers refusal at :235 ("setup-vm.sh never pulls, so: podman pull $img, then re-run…") say the same, and deploy/microvm/tests/setup-microvm.test.sh:370/:388 pin that message. After this PR, re-running setup-vm.sh is enough (unless SH_SKIP_PULL is set).
  • SH_SKIP_PULL with no local copy differs between the two scripts: build-rootfs.sh refuses, but setup-vm.sh warns and lets podman run pull. That contradicts the README's "does not attempt the pull at all".

Author: cwiklik (MEMBER — maintainer)
Areas reviewed: Shell (setup-vm.sh, build-rootfs.sh + tests), Docs
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing (16/16)

Assisted-By: Claude Code

any of `bash git rg python3 base64 file ls cat`. It strips the container
worker binary and records the image and its digest in `/etc/moca-rootfs-source` inside the tree.

It **pulls the reference every run** rather than reusing a copy this host happens to hold: a

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: This paragraph is now correct, but the same doc's step at lines 38-44 still says "setup-vm.sh never pulls: its podman run --replace reuses the image the host already has" and tells operators to podman pull by hand before re-running it. The same claim appears in deploy/microvm/setup-microvm.sh:206 (comment) and in the check_container_tiers refusal at :235 ("setup-vm.sh never pulls, so: podman pull $img, then re-run …"). tests/setup-microvm.test.sh:370/:388 pin that wording. After #414, "re-run deploy/vm/setup-vm.sh" is enough on its own, and the manual pull is only needed with SH_SKIP_PULL. Worth updating all three here (or in a quick follow-up) so the docs stop contradicting the new behaviour.

Comment thread deploy/vm/setup-vm.sh
id="$(podman image inspect --format '{{.Id}}' "$SANDBOX_IMAGE" 2>/dev/null || true)"
created="$(podman image inspect --format '{{.Created}}' "$SANDBOX_IMAGE" 2>/dev/null || true)"
if [[ -z "$id" ]]; then
echo "WARNING: no local copy of $SANDBOX_IMAGE to inspect, so this run cannot report which" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: When SH_SKIP_PULL is set and the host has no copy, this warns and continues, and podman run (default --pull=missing) then pulls from the registry anyway. That contradicts the README's "It does not attempt the pull at all (so there is no registry timeout to wait out)" and the header's "start the sandboxes on whatever copy this host already has". It also differs from build-rootfs.sh, which refuses in the same state (SH_SKIP_PULL is set but this host has no copy). I'd suggest one of two fixes: (a) refuse here when SH_SKIP_PULL is set and there's no local copy, matching build-rootfs.sh, or (b) pass --pull=never to the sandbox podman run under SH_SKIP_PULL. Either way, the warning text "podman will pull it" would then only apply to the pulled path, where it is effectively unreachable.

grep -q 'SH_SKIP_PULL' <<<"$pull_fail_out" ||
fail "the refusal must name the override an offline host needs: $pull_fail_out"
if grep -q 'podman run .*sh-sandbox-' "$MOCK_LOG"; then
fail "a failed pull still started a sandbox container: $(cat "$MOCK_LOG")"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This check can't fail. The case calls pull_sandbox_image alone, never start_sandboxes/main, so no podman run .*sh-sandbox- line can appear. What actually stops the sandboxes is set -e in main() on the non-zero return, and nothing here exercises that. Either drop the check, or run main with MOCK_PODMAN_FAIL='pull *' and assert that no sandbox podman run happened.

@cwiklik
cwiklik merged commit f408d91 into rossoctl:main Oct 29, 2026
16 checks passed
webchang added a commit to webchang/moca that referenced this pull request Nov 2, 2026
Takes upstream's 11 commits after 071b213: gh vendored into the sandbox images (rossoctl#661), the sandbox image pulled on every run in both VM paths (rossoctl#665) and in compose (rossoctl#664), a cached login matched by endpoint (rossoctl#667), a kind-ci fix (rossoctl#663). No conflicts.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deploy/vm: setup-vm.sh never pulls the sandbox image, so a host runs a stale :latest

2 participants