Architecture-aware container image builds in deploy workflows - #12640
Architecture-aware container image builds in deploy workflows#12640sylvainsf wants to merge 6 commits into
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR updates the shared run-rad-commands deploy workflows/actions to compute an effective container image build platform list based on the target cluster’s node architectures, so single-arch clusters avoid slow/flaky QEMU-emulated multi-arch builds while mixed/undetermined clusters keep the multi-arch fallback.
Changes:
- Add
compute-build-platforms.sh(and tests) to resolve effective build platforms from mode/fallback/detected arches. - Wire new
build-arch-mode/build-fallback-platformsinputs through the composite action and Azure/AWS workflow templates. - Inject
--parameters platforms=...only when the app declaresplatformsand it’s not already provided viaRADIUS_DEPLOY_PARAMS; add Make/test coverage.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| build/test.mk | Adds test-build-platforms and includes it in make test. |
| .github/extension/run-rad-commands-azure.yml | Adds template placeholders and passes arch inputs to the shared action. |
| .github/extension/run-rad-commands-aws.yml | Adds template placeholders and passes arch inputs to the shared action. |
| .github/extension/actions/run-rad-commands/action.yml | Declares new inputs and adds a step to detect/compute/export RADIUS_EFFECTIVE_BUILD_PLATFORMS. |
| .github/extension/actions/run-rad-commands/compute-build-platforms.sh | New platform resolver script (mode/fallback/detect logic). |
| .github/extension/actions/run-rad-commands/compute-build-platforms_test.sh | New unit + wiring tests for resolver/workflows/action. |
| .github/extension/actions/run-rad-commands/deploy-parameters.sh | Injects platforms parameter when applicable. |
| .github/extension/actions/run-rad-commands/deploy-parameters_test.sh | Adds coverage for platforms injection behavior. |
Suppressed comments (2)
.github/extension/actions/run-rad-commands/action.yml:113
- This currently suppresses kubectl errors and can hide useful diagnostics (RBAC, connectivity, etc.). Prefer letting stderr through while still degrading to empty ARCHES via
|| true. Also avoidecho "$ARCHES"in command substitution (it can mangle backslashes); use printf instead.
ARCHES=$(kubectl --kubeconfig "$TARGET_KUBECONFIG" get nodes \
-o jsonpath='{range .items[*]}{.status.nodeInfo.architecture}{"\n"}{end}' \
2>/dev/null || true)
echo "Detected target cluster node architectures: $(echo "$ARCHES" | tr '\n' ' ')"
.github/extension/actions/run-rad-commands/compute-build-platforms.sh:66
sortis locale-dependent; without pinning the locale, the "sorted (deterministic) order" guarantee can vary across runner images/locales. Set LC_ALL=C for stable collation.
sort -u |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12640 +/- ##
==========================================
- Coverage 54.19% 54.18% -0.02%
==========================================
Files 770 770
Lines 51085 51085
==========================================
- Hits 27688 27682 -6
- Misses 20790 20793 +3
- Partials 2607 2610 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Functional Tests - corerp-cloud30 tests 29 ✅ 21m 10s ⏱️ Results for commit 4ff4d66. ♻️ This comment has been updated with latest results. |
|
Thanks for the review. Addressed in bd0005c.
The |
Radius.Compute/containerImages builds run in an in-cluster BuildKit compiled for the runner's architecture (amd64 on standard GitHub-hosted runners). When an app leaves build.platforms unset the recipe defaults to multi-arch (linux/amd64,linux/arm64), so the arm64 half builds under QEMU emulation -- much slower and prone to emulation crashes. This lets the deploy workflows build only the platform(s) the target cluster actually runs. Contract (consumed by ai-extensions, radius-project/ai-extensions#300) via two template placeholders on the Azure and AWS run-rad-commands workflows: {{TARGET_CLUSTER_ARCH_MODE}} -> vars.RADIUS_BUILD_ARCH_MODE || 'detect' {{TARGET_CLUSTER_ARCH_FALLBACK_PLATFORMS}} -> vars.RADIUS_BUILD_PLATFORMS || 'linux/amd64,linux/arm64' Behavior (compute-build-platforms.sh, invoked by the shared run-rad-commands action after the target kubeconfig is configured and before the deploy): - mode 'detect', single-arch cluster -> build that one platform (no emulation) - mode 'detect', mixed or undetermined -> fallback platform list - explicit platform list (contains '/') -> honored verbatim, no detection - empty / unsubstituted placeholder -> feature off, recipe default applies The computed list is exported as RADIUS_EFFECTIVE_BUILD_PLATFORMS and injected as `--parameters platforms=<list>` only when the app declares a `platforms` parameter and it was not already supplied via RADIUS_DEPLOY_PARAMS, flowing through the same conditional path as the existing app-image parameter. Apps that do not opt in are unaffected. Tests: - compute-build-platforms_test.sh: mode/detection/override/fallback matrix plus workflow and action wiring assertions (make test-build-platforms). - deploy-parameters_test.sh: platforms injection is gated on declaration, an empty computed list, and RADIUS_DEPLOY_PARAMS precedence. Signed-off-by: Sylvain Niles <sylvainniles@microsoft.com>
…comment - action.yml: default-expand RADIUS_TARGET_KUBECONFIG so an unset value does not trip set -u before the empty case is handled (degrades to fallback). - compute-build-platforms.sh: rewrite the malformed MODE contract header comment (unfinished parenthesis / broken bullet) for readability. Signed-off-by: Sylvain Niles <sylvainniles@microsoft.com>
bd0005c to
84c8ca4
Compare
Signed-off-by: Sylvain Niles <sylvainniles@microsoft.com>
Signed-off-by: Sylvain Niles <sylvainniles@microsoft.com>
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
Functional Tests - dynamicrp-noncloud67 tests ±0 65 ✅ - 2 19m 4s ⏱️ + 1m 6s For more details on these failures, see this check. Results for commit bd55a5b. ± Comparison against base commit 78e12e0. |
Description
Radius.Compute/containerImagesbuilds run in an in-cluster BuildKit that is compiled for the runner's architecture (amd64 on standard GitHub-hosted runners). When an app leavesbuild.platformsunset, the recipe defaults to a multi-arch build (linux/amd64,linux/arm64), so the arm64 half is produced under QEMU emulation, which is roughly an order of magnitude slower and prone to emulation crashes (see the analysis on #12595). This PR lets the Azure and AWS deploy workflows build only the platform(s) the target cluster actually runs, while preserving multi-arch when it is genuinely needed.This is the upstream half of the contract in radius-project/ai-extensions#300.
Contract
Two template placeholders on the Azure and AWS
run-rad-commandsworkflows, rendered by the extension:{{TARGET_CLUSTER_ARCH_MODE}}${{ vars.RADIUS_BUILD_ARCH_MODE || 'detect' }}{{TARGET_CLUSTER_ARCH_FALLBACK_PLATFORMS}}${{ vars.RADIUS_BUILD_PLATFORMS || 'linux/amd64,linux/arm64' }}Behavior
Resolved by
compute-build-platforms.sh, invoked by the sharedrun-rad-commandsaction after the target kubeconfig is configured and before the app is built/deployed:detectdetect/, e.g.linux/amd64)The computed list is exported as
RADIUS_EFFECTIVE_BUILD_PLATFORMSand injected as--parameters platforms=<list>only when the app declares aplatformsparameter and it was not already supplied viaRADIUS_DEPLOY_PARAMS, flowing through the same conditional path as the existingapp-imageparameter. Apps that do not declareplatforms, and templates that do not render the placeholders, are unaffected.Mixed-arch is a first-class outcome, not an error. A cluster with both amd64 and arm64 nodes resolves to the fallback multi-arch list so images stay portable; only single-arch clusters drop to a single platform to skip emulation.
Design notes
detect, an explicit platform list, or empty/placeholder (off). An unrecognized keyword fails safe to the fallback list with a warning, documented in the workflow and script comments.kubectl get nodes -o jsonpath=...nodeInfo.architecture; a failed probe degrades to empty, which the resolver treats as "undetermined" and maps to the fallback.Testing
make test-build-platforms— newcompute-build-platforms_test.sh: mode/detection/override/fallback matrix (single-arch, mixed-arch, unknown-arch, x86_64/aarch64 aliases, normalization, unrecognized mode), plus assertions that both workflows carry the placeholders and wire the inputs, and that the action declares the inputs and runs the helper.make test-run-rad-commands-action— extendeddeploy-parameters_test.sh:platformsis injected only when declared, skipped when no effective list was computed, and never overrides aRADIUS_DEPLOY_PARAMS-supplied value.shellcheckclean on all shell; all three modified YAML files parse.Files
.github/extension/actions/run-rad-commands/compute-build-platforms.sh.github/extension/actions/run-rad-commands/compute-build-platforms_test.sh.github/extension/actions/run-rad-commands/action.ymlbuild-arch-mode/build-fallback-platformsinputs; detection step exportingRADIUS_EFFECTIVE_BUILD_PLATFORMS.github/extension/actions/run-rad-commands/deploy-parameters.shplatformswhen the app declares it and a list was computed.github/extension/actions/run-rad-commands/deploy-parameters_test.sh.github/extension/run-rad-commands-azure.yml/-aws.ymlrun-rad-commandsbuild/test.mktest-build-platformstarget, added totestRelated