Skip to content

[oadp-1.4] Make controller-gen/kustomize/golangci-lint/envtest tool-binary caching reliable - #2368

Open
kaovilai wants to merge 2 commits into
openshift:oadp-1.4from
kaovilai:fix-tool-version-check-oadp-1.4
Open

[oadp-1.4] Make controller-gen/kustomize/golangci-lint/envtest tool-binary caching reliable#2368
kaovilai wants to merge 2 commits into
openshift:oadp-1.4from
kaovilai:fix-tool-version-check-oadp-1.4

Conversation

@kaovilai

@kaovilai kaovilai commented Aug 10, 2026

Copy link
Copy Markdown
Member

Cherry-pick of #2367 to oadp-1.4 — same underlying issue, same fix, plus a live bug I found already merged on this branch.

Part 1: version-checking for controller-gen/kustomize/golangci-lint

go-install-tool-branch only installs a build tool (controller-gen, kustomize, golangci-lint) when the binary is missing, never verifying the pinned version against what's already on disk. Once a binary lands at bin/<branch>/<tool>, it's reused forever — even after CONTROLLER_TOOLS_VERSION/KUSTOMIZE_VERSION/GOLANGCI_LINT_VERSION change — because bin/ is gitignored and nothing else resets it.

kustomize/controller-gen targets also weren't fully .PHONY (only the wrapper name was, not the binary path), so Make's own mtime-based staleness check could skip the recipe entirely before any version-check logic even ran. (oadp-1.4's golangci-lint target didn't have any version-check at all, unlike oadp-dev's partial one — folded into this same fix.)

Fix: added go-install-tool-versioned, which compares a sidecar <binary>.version marker file against the pinned version instead of introspecting the binary's own --version output — unreliable for some tools installed this way. Confirmed in practice: three bin/*/kustomize binaries on this machine, all installed the same way, reported (devel), a literal unexpanded $Format:%H$ git-archive placeholder, and a correct version string respectively.

Part 2: envtest arch-check (already-live bug fix)

This branch already has an envtest arch-check (check-envtest-arch, landed via #2100 back in Feb 2026) — but it's been unconditionally reinstalling setup-envtest on every single make test/make envtest invocation since it merged. It treats any $(ENVTEST) --help failure as "wrong architecture," but setup-envtest's own --help exits 2 by its own convention even on a perfectly working binary. Since check-envtest-arch is itself .PHONY and a prerequisite of $(ENVTEST), that always-nonzero exit forces a delete+reinstall every time, unconditionally — defeating the point of caching this binary at all.

Fixed to check exit code 126 specifically (POSIX "found but cannot execute" / exec format error), not any nonzero exit — verified by cross-compiling a real linux/amd64 setup-envtest and running it on this darwin/arm64 host: the shell reports exit 126 distinctly from the tool's own exit codes.

How I tested (both parts)

  • rm -rf bin/oadp-1.4 / rm -f bin/setup-envtest then make controller-gen / make kustomize / make envtest individually — each installs fresh.
  • Re-running each immediately after → no reinstall, binary mtime unchanged, no network call. (Previously, make envtest on this branch would always redownload — confirmed before my fix.)
  • Simulated a version mismatch (bogus .version marker) for controller-gen/kustomize → correctly detected, removed, reinstalled, marker rewritten.
  • Simulated a wrong-arch binary for envtest (cross-compiled linux/amd64, copied over the native binary) → correctly detected via exit 126, removed, reinstalled with a valid native binary.
  • make generate manifests bundle → zero diff against a clean checkout.
  • make test → exit 0, all packages pass, Go code is formatted, api is up to date, bundle is up to date.

Note: golangci-lint@v1.54.2 (this branch's pin) fails to build against a modern Go toolchain (Go 1.26) in my local sandbox due to an old x/tools transitive dependency incompatibility unrelated to this change. make test on this branch doesn't invoke golangci-lint at all, so this didn't block verification; CI pins its own Go version and isn't affected.

Note

Responses generated with Claude

Cherry-pick of the fix from oadp-dev. go-install-tool-branch only
installs when the binary is missing, never verifying the pinned
version against what's already on disk. Once a binary lands in
bin/<branch>/, it's reused forever across branch switches and version
bumps since bin/ is gitignored and nothing else resets it. kustomize
and controller-gen's targets also weren't fully .PHONY (only the
wrapper name was, not the binary path), so Make's own mtime-based
staleness check could skip their recipe entirely before any version
check ran.

Introduce go-install-tool-versioned, which compares a sidecar
<binary>.version marker file against the pinned version instead of
introspecting the binary's own --version output. Binary introspection
isn't reliable for every tool installed this way: kustomize's `version`
command depends on ldflags its own release process sets, which `go
install` doesn't set, so identically-installed kustomize binaries were
observed reporting "(devel)", an unexpanded `$Format:%H$` git-archive
placeholder, or a correct version string depending on unrelated
build-time factors.

oadp-1.4's golangci-lint target didn't have any version-check at all
(unlike oadp-dev's, which had a partial/broken one), so it's folded
into the same fix here.

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

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a50aa211-7912-41da-970b-4d7a99dd8163

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 10, 2026
Joeavaikath
Joeavaikath previously approved these changes Aug 10, 2026
@codecov-commenter

codecov-commenter commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.25000% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.47%. Comparing base (42938ce) to head (f559de7).
⚠️ Report is 4 commits behind head on oadp-1.4.

⚠️ Current head f559de7 differs from pull request most recent head af5468b

Please upload reports for the commit af5468b to get more accurate results.

Files with missing lines Patch % Lines
api/v1alpha1/zz_generated.deepcopy.go 0.00% 12 Missing ⚠️
pkg/common/common.go 95.16% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           oadp-1.4    #2368      +/-   ##
============================================
+ Coverage     37.79%   38.47%   +0.67%     
============================================
  Files            30       30              
  Lines          5033     5113      +80     
============================================
+ Hits           1902     1967      +65     
- Misses         2935     2949      +14     
- Partials        196      197       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch's check-envtest-arch (landed via openshift#2100, Feb 2026) has been
unconditionally reinstalling setup-envtest on every single
`make test`/`make envtest` invocation since it merged: it treats any
`$(ENVTEST) --help` failure as "wrong architecture," but setup-envtest's
own --help exits 2 by its own convention even on a perfectly working
binary. Since check-envtest-arch is itself .PHONY and a prerequisite of
$(ENVTEST), that always-nonzero exit forces a delete+reinstall on every
invocation, unconditionally, defeating the point of caching this binary
at all.

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) for
a genuinely incompatible binary, distinct from the tool's own exit
codes. Check that instead.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
@kaovilai kaovilai changed the title [oadp-1.4] Make controller-gen/kustomize/golangci-lint version checks reliable [oadp-1.4] Make controller-gen/kustomize/golangci-lint/envtest tool-binary caching reliable Aug 12, 2026
@openshift-ci

openshift-ci Bot commented Aug 12, 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

1 similar comment
@openshift-ci

openshift-ci Bot commented Aug 12, 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 commented Aug 12, 2026

Copy link
Copy Markdown

@kaovilai: all tests passed!

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.

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.

3 participants