fix(python-multiversion-uv): derive broker arch from AVOCADO_SDK_TARGET#22
fix(python-multiversion-uv): derive broker arch from AVOCADO_SDK_TARGET#22bbrock25 wants to merge 1 commit into
Conversation
The broker compile step detected the target arch by probing the SDK container's python3 (platform.machine()). That assumed an x86_64 SDK host where only the target python is emulated. On arm64 hosts (Apple Silicon) the SDK container is natively aarch64, so the probe returned aarch64 for every target and shipped an arm64 nats-server into x86-64 images. The service then failed with an exec format error and the apps looped on ConnectionRefusedError against 127.0.0.1:4222. Resolve the arch from AVOCADO_SDK_TARGET instead, matching the app compile scripts in this reference (which document this exact trap). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jetm
left a comment
There was a problem hiding this comment.
Arch mapping is correct for the three supported targets (qemux86-64 -> amd64, raspberrypi4/5 -> arm64). Two things to fix before merge, inline: the new catch-all drops the old fail-loud default so a missing/empty AVOCADO_SDK_TARGET silently builds an arm64 broker (MEDIUM), and the comment's claim that this mirrors the app compile scripts is inaccurate.
| # host and target differ (e.g. an arm64 Mac building for qemux86-64). | ||
| case "$AVOCADO_SDK_TARGET" in | ||
| *x86-64*|*x86_64*) NARCH=amd64 ;; | ||
| *) NARCH=arm64 ;; |
There was a problem hiding this comment.
This catch-all replaces the old explicit arm64 arm plus a fail-loud *) exit 1. With only set -e (no set -u), an unset or empty AVOCADO_SDK_TARGET falls through to arm64 - so if a CLI version doesn't export it into this compile hook (the sibling app-compile scripts never read AVOCADO_SDK_TARGET, so its presence here is an assumption worth confirming), a qemux86-64 build silently downloads the linux-arm64 nats-server and fails to exec on the x86_64 device at runtime, with no build-time error. That's a robustness regression vs the code being replaced. Suggest guarding with : "${AVOCADO_SDK_TARGET:?AVOCADO_SDK_TARGET not set}" and keeping a hard-fail *) for unrecognized targets (which also stops a future riscv / 32-bit-arm target from silently mapping to arm64). Mapping is otherwise correct for the three supported targets.
| x86_64) NARCH=amd64 ;; | ||
| aarch64 | arm64) NARCH=arm64 ;; | ||
| *) echo "[broker] unsupported target arch: $TARGET_ARCH" >&2; exit 1 ;; | ||
| # Resolve the TARGET arch from AVOCADO_SDK_TARGET, the same way the app |
There was a problem hiding this comment.
The comment says this derives arch "the same way the app compile scripts do," but none of them do - app311/app314 rely on uv autodetecting the arch inside the SDK container and app312 uses the system python3. The broker genuinely differs (it downloads a prebuilt GitHub binary, so it can't lean on uv autodetection), so the approach is fine - but the cited precedent doesn't exist, and the new comment ("runtime probes report the HOST arch") contradicts the old one it replaced ("the target python3 reports the real target arch"). Worth reconciling the rationale.
Summary
python3(platform.machine()), assuming an x86_64 SDK host where only the target python is emulated via binfmt.aarch64for every target — shipping an arm64nats-serverinto qemux86-64 images.nats.servicethen failed with an exec format error (status=203/EXEC) and all three apps looped onConnectionRefusedErroragainst127.0.0.1:4222, while the image otherwise built and booted cleanly.$AVOCADO_SDK_TARGETinstead, matching the app compile scripts in this reference (whose comments document this exact host-vs-target trap).Test plan
avocado buildforqemux86-64: broker step logsnats-server ... for linux-amd64andfile broker/bin/nats-serverreportsx86-64(previouslyARM aarch64)avocado provision dev+avocado sdk run -iE vm dev:nats.serviceactive, app314 logspipeline_completewith the 3.11/3.12/3.14 chainraspberrypi5, same arm64 host): full build succeeds; broker step logsnats-server ... for linux-arm64andfileconfirmsARM aarch64for the broker binary, shipped interpreter, and numpy.sosNote for reviewers: existing checkouts may have a stale wrong-arch binary cached at
broker/bin/nats-server;broker-clean.sh(or a full clean) is needed once after this change.🤖 Generated with Claude Code