diff --git a/Makefile b/Makefile index 8d3dabb8d18..265a5c136f7 100644 --- a/Makefile +++ b/Makefile @@ -300,10 +300,12 @@ vet: check-go ## Run go vet against code. go vet -mod=mod ./... ENVTEST := $(shell pwd)/bin/setup-envtest -ENVTESTPATH = $(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path) -ifeq ($(shell $(ENVTEST) list | grep $(ENVTEST_K8S_VERSION)),) - ENVTESTPATH = $(shell $(ENVTEST) --arch=amd64 use $(ENVTEST_K8S_VERSION) -p path) -endif +# Native-arch resolution first, falling back to amd64 only if that fails (e.g. no +# native-arch envtest assets published for this k8s version). Done as a single shell +# expression (not a make ifeq) so it's decided when ENVTESTPATH is actually referenced +# in a recipe, after $(ENVTEST) is guaranteed installed for the host's real arch -- +# not at Makefile-parse time against a possibly-cold bin/ (see issue #2377). +ENVTESTPATH = $(shell out=$$($(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path 2>/dev/null); if [ -z "$$out" ]; then out=$$($(ENVTEST) --arch=amd64 use $(ENVTEST_K8S_VERSION) -p path 2>/dev/null); fi; echo "$$out") .PHONY: check-envtest-arch check-envtest-arch: @if [ -f $(ENVTEST) ] && ! $(ENVTEST) --help >/dev/null 2>&1; then \