Skip to content

fix: use native platform for Dockerfile builder stage to avoid QEMU arm64 failures#3157

Open
andyzhangx wants to merge 2 commits into
kubernetes-sigs:masterfrom
andyzhangx:fix-arm64-qemu-build
Open

fix: use native platform for Dockerfile builder stage to avoid QEMU arm64 failures#3157
andyzhangx wants to merge 2 commits into
kubernetes-sigs:masterfrom
andyzhangx:fix-arm64-qemu-build

Conversation

@andyzhangx
Copy link
Copy Markdown
Member

@andyzhangx andyzhangx commented May 17, 2026

What type of PR is this?
/kind bug

What this PR does / why we need it:
The builder stage in the Dockerfile runs apt install curl under QEMU emulation when building arm64 images on amd64 CI hosts. This intermittently fails with Exec format error when the binfmt registration is unstable in Docker-in-Docker environments.

By using --platform=$BUILDPLATFORM, the builder stage always runs natively (amd64) and downloads the correct arch-specific azcopy binary via TARGETARCH. This eliminates the QEMU dependency for the builder stage while keeping the final image on the correct target architecture.

How BUILDPLATFORM and TARGETARCH work:

Both BUILDPLATFORM and TARGETARCH are BuildKit automatic platform ARGs. When using docker buildx build --platform=linux/<arch>, BuildKit automatically injects the correct values, overriding any Dockerfile defaults:

  • make container-linux ARCH=arm64--platform=linux/arm64 → BuildKit sets TARGETARCH=arm64 → downloads azcopy_linux_arm64_10.32.4.tar.gz
  • make container-linux ARCH=amd64--platform=linux/amd64 → BuildKit sets TARGETARCH=amd64 → downloads azcopy_linux_amd64_10.32.4.tar.gz
  • Plain docker build (no buildx) → no injection → falls back to defaults (BUILDPLATFORM=linux/amd64, TARGETARCH=amd64) ✅

The defaults (BUILDPLATFORM=linux/amd64, TARGETARCH=amd64) are only a safety net for non-BuildKit builds. In CI, container-linux always uses docker buildx --platform="linux/$(ARCH)", so BuildKit injects the actual target arch automatically.

Which issue(s) this PR fixes:
Fixes intermittent arm64 image build failures in CI (e.g. pull-azurefile-csi-driver-external-e2e-nfs).

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label May 17, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andyzhangx

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested review from cvvz and gnufied May 17, 2026 03:07
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 17, 2026
@andyzhangx andyzhangx requested a review from Copilot May 17, 2026 03:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Linux plugin image build to avoid running the builder stage under QEMU emulation when producing arm64 images on amd64 CI hosts, reducing intermittent Exec format error failures during apt install in the builder stage.

Changes:

  • Run the builder stage using --platform=$BUILDPLATFORM so it executes natively on the build host.
  • Switch azcopy download selection from a custom ARCH arg to BuildKit’s TARGETARCH.

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

Comment thread pkg/azurefileplugin/Dockerfile Outdated
Comment thread pkg/azurefileplugin/Dockerfile Outdated
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 17, 2026
@andyzhangx andyzhangx requested a review from Copilot May 17, 2026 04:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

The builder stage only needs to download azcopy binaries and the
Microsoft apt repo deb. Running apt install under QEMU emulation
for arm64 intermittently fails with 'Exec format error' when
binfmt registration is unstable in CI Docker-in-Docker environments.

By using --platform=$BUILDPLATFORM, the builder always runs natively
(amd64) and downloads the correct arch-specific azcopy binary via
TARGETARCH, eliminating the QEMU dependency for this stage.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread pkg/azurefileplugin/Dockerfile
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Give TARGETARCH a default of 'amd64' so the azcopy download URL
is always valid even when not running under BuildKit/buildx.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants