Change:
<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --What happened: when building images on non-amd platform, arm64 for example, and the target image is arm64 too, the code still reset . What you expected to happen: There is no need to reset anything, the shell code is purely for amd64 and haven't considered the non-amd platforms. How to reproduce it (as minimally and precisely as possible): on any platform other than amd, cd test/images build all WHAT=echoserver (or any image under the dir) when coming to image which is exactly the same as the build machine, following is seen from console Anything else we need to know?: Environment: Kubernetes version (use ): latest Cloud provider or hardware configuration: OS (e.g: ): all Kernel (e.g. ): all Install tools: Network plugin and version (if this is a network-related bug): Others:
/assign
/sig testing
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale
/remove-lifecycle stale
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale
Stale issues rot after 30d of inactivity. Mark the issue as fresh with . Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle rotten
/remove-lifecycle rotten this issue still stands.
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale
Stale issues rot after 30d of inactivity. Mark the issue as fresh with . Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle rotten
Rotten issues close after 30d of inactivity. Reopen the issue with . Mark the issue as fresh with . Send feedback to sig-testing, kubernetes/test-infra and/or . /close
Closing this issue. <detailsIn response to : Rotten issues close after 30d of inactivity. Reopen the issue with . Mark the issue as fresh with . /close Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/lifecycle frozen
/remove-lifecycle rotten
/reopen
Reopened this issue. <detailsIn response to : /reopen Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
triage/accepted
/triage accepted

Discussion:
base_image="" if [[ -f BASEIMAGE ]]; then <del> base_image=$(getBaseImage "${os_arch}" | ${SED} "s|REGISTRY|${REGISTRY}|g") ${SED} -i "s|BASEARCH|${arch}|g" $dockerfile_name </del> <ins> base_image=$(getBaseImage "${os_arch}" | "${SED}" "s|REGISTRY|${REGISTRY}|g") "${SED}" -i "s|BASEARCH|${arch}|g" $dockerfile_name </ins> fi <del> # copy the qemu-*-static binary to docker image to build the multi architecture image on x86 platform if grep -q "CROSS_BUILD_" Dockerfile; then if [[ "${arch}" == "amd64" ]]; then ${SED} -i "/CROSS_BUILD_/d" Dockerfile else ${SED} -i "s|QEMUARCH|${QEMUARCHS[$arch]}|g" Dockerfile # Register qemu-*-static for all supported processors except the current one echo "Registering qemu-*-static binaries in the kernel" local sudo="" if [[ $(id -u) != 0 ]]; then sudo=sudo </del> <ins> # Only the cross-build on x86 is guaranteed by far, other arches like aarch64 doesn't support cross-build # thus, there is no need to tackle a disability feature on those platforms, and also help to prevent from # ending up a wrong image tag on non-amd64 platforms. build_arch=$(uname -m) if [[ ${build_arch} = 'x86_64' ]]; then # copy the qemu-*-static binary to docker image to build the multi architecture image on x86 platform if grep -q 'CROSS_BUILD_' Dockerfile; then if [[ "${arch}" = 'amd64' ]]; then "${SED}" -i '/CROSS_BUILD_/d' Dockerfile else "${SED}" -i "s|QEMUARCH|${QEMUARCHS[$arch]}|g" Dockerfile # Register qemu-*-static for all supported processors except the current one echo 'Registering qemu-*-static binaries in the kernel' local sudo if [[ $(id -u) -ne 0 ]]; then sudo=sudo fi ${sudo} "${KUBE_ROOT}/third_party/multiarch/qemu-user-static/register/register.sh" --reset -p yes curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/"${QEMUVERSION}"/x86_64_qemu-"${QEMUARCHS[$arch]}"-static.tar.gz | tar -xz -C "${temp_dir}" # Ensure we don't get surprised by umask settings chmod 0755 "${temp_dir}/qemu-${QEMUARCHS[$arch]}-static" "${SED}" -i 's/CROSS_BUILD_//g' Dockerfile fi </ins> fi <del> ${sudo} "${KUBE_ROOT}/third_party/multiarch/qemu-user-static/register/register.sh" --reset -p yes curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/"${QEMUVERSION}"/x86_64_qemu-"${QEMUARCHS[$arch]}"-static.tar.gz | tar -xz -C "${temp_dir}" # Ensure we don't get surprised by umask settings chmod 0755 "${temp_dir}/qemu-${QEMUARCHS[$arch]}-static" ${SED} -i "s/CROSS_BUILD_//g" Dockerfile fi </del> <ins> elif [[ "${QEMUARCHS[$arch]}" != "${build_arch}" ]]; then echo "skip cross-build $arch on non-supported platform ${build_arch}." popd continue else "${SED}" -i '/CROSS_BUILD_/d' Dockerfile </ins> fi docker buildx build --progress=plain --no-cache --pull --output=type="${output_type}" --platform "${os_name}/${arch}" 

# reset manifest list; needed in case multiple images are being built / pushed. manifest=() # Make os_archs list into image manifest. Eg: 'linux/amd64 linux/ppc64le' to '${REGISTRY}/${image}:${TAG}-linux-amd64 ${REGISTRY}/${image}:${TAG}-linux-ppc64le' <del> while IFS='' read -r line; do manifest+=("$line"); done < <(echo "$os_archs" | ${SED} "s~/~-~g" | ${SED} -e "s~[^ ]*~$REGISTRY/$image:$TAG-&~g") </del> <ins> while IFS='' read -r line; do manifest+=("$line"); done < <(echo "$os_archs" | "${SED}" "s~/~-~g" | "${SED}" -e "s~[^ ]*~$REGISTRY/$image:$TAG-&~g") </ins> docker manifest create --amend "${REGISTRY}/${image}:${TAG}" "${manifest[@]}" # We will need the full registry name in order to set the "os.version" for Windows images.