Skip to content

fix(testing): gate ctr image import --local by detected ctr version - #1177

Open
HarnageaGabriel wants to merge 4 commits into
containerd:mainfrom
HarnageaGabriel:fix-issue-579-ctr-import-local
Open

fix(testing): gate ctr image import --local by detected ctr version#1177
HarnageaGabriel wants to merge 4 commits into
containerd:mainfrom
HarnageaGabriel:fix-issue-579-ctr-import-local

Conversation

@HarnageaGabriel

Copy link
Copy Markdown

Summary

Fixes #579.

The Makefile load target originally reported in this issue (ctr -n default image import --all-platforms dist/img.tar) no longer exists — it was removed in 570a9fe (Jan 2025), well after this issue was filed, when the project switched to pulling published images instead of importing locally built ones.

The same underlying bug is still present in crates/containerd-shim-wasm/src/testing.rs, import_image(), which is used by the real test suite (3 call sites) and shells out to ctr -n <ns> image import --all-platforms <tar>. On containerd v2.0+ this fails with:

ctr: rpc error: code = InvalidArgument desc = unable to initialize unpacker: no unpack platforms defined: invalid argument

The known workaround is --local (containerd/containerd#7592), but that flag doesn't exist on ctr < 1.7.7, and runwasi still supports ctr as old as 1.6.25 — so the flag can't be added unconditionally.

Changes

  • Detect the installed ctr version at runtime via ctr --version and parse it with semver.
  • Only append --local when the detected version is >= 1.7.7.
  • If version detection fails for any reason, fall back to the old behavior (no --local) rather than failing the test helper.
  • semver added as an optional dependency gated behind the existing testing feature; it was already present in Cargo.lock via another crate, so the lock only gained one line.

Test plan

  • git diff --check clean, changes scoped to 3 files
  • Could not run cargo check/cargo build in the environment this was authored in (no local Rust toolchain) — relying on CI to compile-check
  • Would appreciate a run on both an old ctr (1.6.x) and new ctr (2.0+) if a maintainer can verify the version gate against real binaries

ctr image import --all-platforms fails on containerd v2.0+ with
"unable to initialize unpacker: no unpack platforms defined:
invalid argument" (containerd/containerd#7592). The fix is passing
--local, but that flag does not exist on ctr < 1.7.7, and runwasi
still supports ctr as old as 1.6.25. Detect the ctr version at
runtime via `ctr --version` and only add --local when >= 1.7.7,
falling back to the old behavior if detection fails.

Fixes containerd#579

Signed-off-by: HarnageaGabriel <gabriel.harnagea06@gmail.com>
The generated test images contain WASM content but declare no rootfs
diff IDs. Running ctr's local unpack path is unnecessary and can leave
snapshot cleanup racing later stress tests, causing intermittent
"parent snapshot ... does not exist" failures.

Keep legacy ctr imports unchanged while retaining --local for versions
that require it.

Signed-off-by: HarnageaGabriel <gabriel.harnagea06@gmail.com>
@HarnageaGabriel
HarnageaGabriel force-pushed the fix-issue-579-ctr-import-local branch from 7003a77 to e1c019b Compare August 12, 2026 16:59
- wrap bare URL in vendor/containerd_shim/mod.rs in angle brackets
- drop private intra-doc link to OtlpConfig in shim/mod.rs module doc

Pre-existing warnings unrelated to this PR's diff, surfaced by RUSTFLAGS=-D warnings in the docs job and blocking CI green.
…ll download)

Signed-off-by: HarnageaGabriel <gabriel.harnagea06@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"no unpack platforms defined: invalid argument" happens when make load

1 participant