Skip to content

fix(runner): pull snapshot layers for the host arch, not hardcoded amd64#671

Merged
DorianZheng merged 1 commit into
boxlite-ai:mainfrom
lilongen:fix/runner-pull-host-arch
Jun 8, 2026
Merged

fix(runner): pull snapshot layers for the host arch, not hardcoded amd64#671
DorianZheng merged 1 commit into
boxlite-ai:mainfrom
lilongen:fix/runner-pull-host-arch

Conversation

@lilongen

@lilongen lilongen commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

PullSnapshot hardcoded linux/amd64 when pulling snapshot image layers. On a non-amd64 runner host (e.g. an Apple Silicon dev runner) that pulls x86 layers, so /bin/sh and other binaries land as x86 ELF and fail with ENOEXEC: Exec format error the moment libkrun execs them inside the microVM.

Fix: use runtime.GOARCH so the pulled image matches the architecture of the host that will actually run it. Also renames the now-misleading linuxAmd64PlatformlinuxHostPlatform.

Why a separate PR

Extracted from the infra-local stack PR (#595) per review — it's a general runner correctness fix unrelated to the local-dev stack, so it should land and be reviewed on its own.

Test

Adds TestLinuxHostPlatformMatchesHostArch asserting the pull platform tracks runtime.GOARCH (fails if re-hardcoded to a fixed arch on a mismatched host). Verified on arm64:

go test ./pkg/boxlite/ -run TestLinuxHostPlatform -v   # PASS

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Registry operations now dynamically detect the host system's processor architecture, ensuring container image pulls and related operations are compatible with the runner's actual hardware rather than relying on a hardcoded value.

The snapshot puller hardcoded linux/amd64. On a non-amd64 runner host
(e.g. Apple Silicon dev runners) that pulls x86 layers, so /bin/sh and
other binaries land as x86 ELF and fail with `ENOEXEC: Exec format error`
when libkrun execs them inside the microVM. Use runtime.GOARCH so the
pulled image matches the host that will run it; rename the now-misleading
linuxAmd64Platform to linuxHostPlatform.

Adds a regression test asserting the platform tracks runtime.GOARCH
(fails if re-hardcoded to a fixed arch on a mismatched host).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 8, 2026 04:58
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dfc87ccc-63c6-4481-8711-61eadc341c42

📥 Commits

Reviewing files that changed from the base of the PR and between b302fce and 14ee179.

📒 Files selected for processing (2)
  • apps/runner/pkg/boxlite/registry.go
  • apps/runner/pkg/boxlite/registry_test.go

📝 Walkthrough

Walkthrough

This PR updates the boxlite registry package to select image manifests compatible with the runner's host architecture at startup. Instead of requesting a hardcoded linux/amd64 manifest, registry operations now detect and use runtime.GOARCH, ensuring pulls and snapshots work on non-amd64 hosts. A test verifies the platform configuration is correct.

Changes

Dynamic host-architecture registry platform

Layer / File(s) Summary
Host architecture platform detection
apps/runner/pkg/boxlite/registry.go
Import runtime package, define linuxHostPlatform with runtime.GOARCH for dynamic architecture selection, and update remoteOptions to use this platform instead of a hardcoded amd64 constant.
Platform architecture validation
apps/runner/pkg/boxlite/registry_test.go
Import runtime and add TestLinuxHostPlatformMatchesHostArch to assert linuxHostPlatform.OS is "linux" and linuxHostPlatform.Architecture equals runtime.GOARCH.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A runner on ARM now hops with glee,
No more amd64 chains, from x86 free,
Runtime detects what arch we call home—
Dynamic platforms wherever we roam! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing snapshot layer pulling to use the host architecture instead of a hardcoded amd64 value.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@cla-assistant

cla-assistant Bot commented Jun 8, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


lile seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant

cla-assistant Bot commented Jun 8, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


lile seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates registry image pulls to target the runner host’s CPU architecture instead of hardcoding linux/amd64, preventing pulling incompatible image layers on non-amd64 hosts (e.g., Apple Silicon).

Changes:

  • Replace the fixed linux/amd64 pull platform with a linux/<host-arch> platform derived from runtime.GOARCH.
  • Update remote registry options to use the new platform.
  • Add a regression test to ensure the selected platform architecture matches the process architecture.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apps/runner/pkg/boxlite/registry.go Switch default remote pull platform from hardcoded amd64 to runtime.GOARCH.
apps/runner/pkg/boxlite/registry_test.go Add a test to assert default pull platform matches runtime.GOARCH and OS is linux.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +20 to +27
// Default registry-pull platform. Daytona's original hardcode of
// `linux/amd64` is correct for prod EC2 runners but breaks on Apple Silicon
// (`/bin/sh` lands as x86 ELF → `ENOEXEC: Exec format error` when libkrun
// tries to exec inside the microVM). Detect at startup based on host arch.
var linuxHostPlatform = v1.Platform{
OS: "linux",
Architecture: runtime.GOARCH, // "amd64", "arm64", etc.
}
Comment on lines +24 to +27
var linuxHostPlatform = v1.Platform{
OS: "linux",
Architecture: runtime.GOARCH, // "amd64", "arm64", etc.
}
lilongen pushed a commit to lilongen/boxlite that referenced this pull request Jun 8, 2026
…r infra-local

Re-add the OIDC user-create default-region fix that was split to PR boxlite-ai#668.
Removing it from this branch broke infra-local: a fresh Dex login creates a
Personal org with defaultRegionId=NULL, and dashboard create-sandbox then
fails with HTTP 428 "organization does not have a default region" (caught by
E2E). Like the runner arm64 (boxlite-ai#671) and cron orderby (boxlite-ai#672) fixes, this is a
general fix the local stack depends on, so it stays in-branch until boxlite-ai#668
lands on main; it drops from this PR's diff on the next rebase.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@DorianZheng DorianZheng merged commit 2e1c6e1 into boxlite-ai:main Jun 8, 2026
10 of 11 checks passed
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.

3 participants