Skip to content

Add --pull flag to control image pull policy - #123

Merged
JAORMX merged 1 commit into
mainfrom
jaosorior/pull-policy
Apr 15, 2026
Merged

Add --pull flag to control image pull policy#123
JAORMX merged 1 commit into
mainfrom
jaosorior/pull-policy

Conversation

@JAORMX

@JAORMX JAORMX commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds --pull flag with four modes: always, background (default), if-not-present, never
  • background (default) uses cached image for instant VM start, refreshes from registry in a background goroutine so the next run picks up any newer image
  • always checks registry synchronously before VM boots (blocks start ~100-500ms)
  • if-not-present uses cache if available, pulls on miss (previous implicit behavior)
  • never uses cache only, fails if not cached (airgapped/offline/CI)
  • Supports config file (image.pull) with CLI override; bbox config init documents the new section
  • Detects --no-image-cache + --pull=never conflict early
  • No go-microvm changes required — uses existing WithImageFetcher and ref index manipulation

Closes #86

Test plan

  • task fmt — no formatting issues
  • task lint — 0 issues
  • task test — all 27 packages pass (15 new tests across 3 packages)
  • Manual: bbox claude-code --pull always blocks on registry check
  • Manual: bbox claude-code --pull background starts instantly, logs background refresh
  • Manual: bbox claude-code --pull never fails if image not cached
  • Manual: bbox claude-code --no-image-cache --pull never errors immediately
  • Manual: config file image.pull: always is respected, CLI overrides it

🤖 Generated with Claude Code

Adds a --pull flag with four modes to control OCI image pulling:

- always: check registry before VM boots (blocks start)
- background: use cached image instantly, refresh in background (default)
- if-not-present: use cache if available, pull on miss
- never: cache only, fail if not cached (airgapped/CI)

The "background" default gives zero-latency starts while keeping images
fresh within one session lag. The registry check and optional extraction
happen in a fire-and-forget goroutine after the VM boots.

Implementation requires no go-microvm changes:
- "always" deletes the ref index entry before microvm.Run(), forcing a
  registry manifest fetch while the digest cache avoids re-extraction
- "never" injects a neverPullFetcher via WithImageFetcher that errors
  on cache miss
- "background" spawns a goroutine after VM start that does the same
  ref-delete + PullWithFetcher flow asynchronously

Closes #86

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JAORMX
JAORMX merged commit 13c2a18 into main Apr 15, 2026
8 checks passed
@JAORMX
JAORMX deleted the jaosorior/pull-policy branch April 15, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --pull flag to control image pull policy

1 participant