Skip to content

Remove setup-envtest if different arch during make test - #2152

Closed
kaovilai wants to merge 1 commit into
openshift:oadp-devfrom
kaovilai:envtest-autoremove-diffarch
Closed

Remove setup-envtest if different arch during make test#2152
kaovilai wants to merge 1 commit into
openshift:oadp-devfrom
kaovilai:envtest-autoremove-diffarch

Conversation

@kaovilai

@kaovilai kaovilai commented Apr 7, 2026

Copy link
Copy Markdown
Member

Signed-off-by: Tiger Kaovilai tkaovila@redhat.com

Why the changes were made

How to test the changes made

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
Copilot AI review requested due to automatic review settings April 7, 2026 21:46
@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8b292e31-8876-4c92-9ce0-1ec8dafb022d

📥 Commits

Reviewing files that changed from the base of the PR and between 3cceb1e and 5097978.

📒 Files selected for processing (1)
  • Makefile

Walkthrough

Modified the envtest tool-install recipe in a Makefile to detect and remove incompatible binaries before reinstalling. If an existing $(ENVTEST) binary fails the --help command check, it is removed before fresh installation via go-install-tool.

Changes

Cohort / File(s) Summary
Build Tool Configuration
Makefile
Added platform compatibility validation to envtest target. Removes incompatible binary if it exists and --help fails, before reinstalling via go-install-tool.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@kaovilai

kaovilai commented Apr 7, 2026

Copy link
Copy Markdown
Member Author

/cc @shubham-pampattiwar @mpryc

@openshift-ci

openshift-ci Bot commented Apr 7, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kaovilai

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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 aims to make make test more reliable by automatically cleaning up an incompatible setup-envtest binary that may have been written into the shared bin/ directory by a container build targeting a different architecture.

Changes:

  • Adds a pre-check in the setup-envtest installation rule to remove an existing setup-envtest binary if it can’t be executed on the current platform.
  • Documents the cross-architecture scenario that can cause make test failures due to a non-native binary in bin/.

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

Comment thread Makefile
Comment on lines 327 to 334
.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)

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

The incompatibility check is inside the $(ENVTEST) file target recipe, but that recipe won’t run when $(ENVTEST) already exists and is considered up-to-date. In the exact scenario this PR describes (a wrong-arch bin/setup-envtest already present), make test will usually skip this recipe and the bad binary won’t be removed. Consider making the compatibility check run unconditionally (e.g., move the check into the .PHONY: envtest target, or add a phony FORCE prerequisite to $(ENVTEST) so the recipe always executes; go-install-tool already avoids re-installing when the file is present).

Copilot uses AI. Check for mistakes.
@kaovilai

Copy link
Copy Markdown
Member Author

/retest

@kaovilai

Copy link
Copy Markdown
Member Author

/override ci/prow/4.23-e2e-test-aws

@kaovilai
kaovilai requested a review from weshayutin April 30, 2026 22:43
@openshift-ci

openshift-ci Bot commented Apr 30, 2026

Copy link
Copy Markdown

@kaovilai: Overrode contexts on behalf of kaovilai: ci/prow/4.23-e2e-test-aws

Details

In response to this:

/override ci/prow/4.23-e2e-test-aws

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci

openshift-ci Bot commented Aug 7, 2026

Copy link
Copy Markdown

@kaovilai: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/5.0-e2e-test-kubevirt-aws 5097978 link true /test 5.0-e2e-test-kubevirt-aws

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

kaovilai added a commit to kaovilai/oadp-operator that referenced this pull request Aug 12, 2026
Folds in the fix from openshift#2152 (same author, same theme: harden
Makefile tool-binary caching under bin/). A containerized Make target
(e.g. podman/docker build with a different GOARCH) can write a linux
binary into the shared bin/ directory, replacing the native host
binary `make test` needs — and since setup-envtest isn't
branch-scoped like the other three tools, that binary is shared
across every branch checkout too.

openshift#2152's own check used `$(ENVTEST) --help`'s exit code as the
"is this binary compatible" signal, but that's unreliable the same
way relying on kustomize's --version output was: setup-envtest's own
--help exits 2 by its own convention even on a perfectly good binary,
so that check would have triggered a reinstall on every single
invocation, permanently defeating the cache. Verified by
cross-compiling a real linux/amd64 setup-envtest and running it on
this darwin/arm64 host: the shell reports exit code 126 specifically
(POSIX "found but cannot execute" / exec format error) — check that
instead of any nonzero exit.

Also added $(ENVTEST) to the .PHONY line, matching the fix already
applied to controller-gen/kustomize in the previous commit: without
it, Make's own mtime-based staleness check can skip the recipe (and
therefore this check) entirely once the binary file exists.

Closes openshift#2152

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
@kaovilai

Copy link
Copy Markdown
Member Author

Folding this into #2367 to reduce review load — closing in favor of that PR, which covers this fix plus the same underlying issue for controller-gen/kustomize/golangci-lint.

Along the way I found the --help-exit-code check here would have triggered a reinstall on every make envtest invocation (setup-envtest's own --help exits 2 by its own convention, even on a working binary) — #2367 checks for exit code 126 specifically (exec format error) instead, verified against a real cross-compiled linux/amd64 binary run on darwin/arm64.

Note

Responses generated with Claude

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants