From 5097978b1b9a8e125caa18950cba6cef5e611e65 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Tue, 7 Apr 2026 17:46:30 -0400 Subject: [PATCH] Remove setup-envtest if different arch during `make test` Signed-off-by: Tiger Kaovilai --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 9d10c0d358b..212d8f45474 100644 --- a/Makefile +++ b/Makefile @@ -320,9 +320,17 @@ $(CONTROLLER_GEN): $(LOCALBIN) fi @ln -sf "$(LOCALBIN)/$(BRANCH_VERSION)/controller-gen" "$(LOCALBIN)/controller-gen" +# Remove setup-envtest if it exists but cannot execute on this platform. +# This can happen when a containerized Make target (e.g. podman/docker build +# with a different GOARCH) writes a linux binary into the shared bin/ directory, +# replacing the native host binary needed by `make test`. .PHONY: envtest envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. $(ENVTEST): $(LOCALBIN) + @if [ -f $(ENVTEST) ] && ! $(ENVTEST) --help >/dev/null 2>&1; then \ + echo "Removing incompatible setup-envtest binary"; \ + rm -f $(ENVTEST); \ + fi $(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20250308055145-5fe7bb3edc86) .PHONY: operator-sdk