Skip to content

ci: replace unverified test binary downloads with setup-envtest - #488

Open
sozercan wants to merge 1 commit into
masterfrom
codex/fix-unverified-binary-downloads-in-ci-workflow
Open

ci: replace unverified test binary downloads with setup-envtest#488
sozercan wants to merge 1 commit into
masterfrom
codex/fix-unverified-binary-downloads-in-ci-workflow

Conversation

@sozercan

@sozercan sozercan commented Apr 9, 2026

Copy link
Copy Markdown
Member

Motivation

  • The test workflow downloaded multiple executables (kubebuilder, kube-apiserver, kubectl, etcd) with curl and installed them without checksum or signature verification, creating a supply-chain risk if upstream artifacts or transport are compromised.

Description

  • Removed the manual curl/tar/chmod/mv installation sequence from .github/workflows/workflow.yaml and replaced it with setup-envtest provisioning.
  • Added go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest and invoked setup-envtest use to fetch envtest binaries into a local directory.
  • Created ${HOME}/kubebuilder/bin and exported KUBEBUILDER_ASSETS into GITHUB_ENV so the existing test step continues to find envtest binaries.

Testing

  • Ran go test ./... in this environment which timed out (EXIT:124), and the workflow file change was validated by inspecting the modified workflow.yaml lines to ensure the unverified downloads were removed and setup-envtest is used instead.

Codex Task

Copilot AI review requested due to automatic review settings April 9, 2026 19:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates CI to avoid directly downloading and installing Kubernetes-related test binaries via curl by switching the test workflow to provision envtest assets using setup-envtest, reducing supply-chain risk from unverified artifacts.

Changes:

  • Replaced manual curl/tar installation of kubebuilder/kube-apiserver/kubectl/etcd with setup-envtest use.
  • Provisioned envtest binaries into ${HOME}/kubebuilder/bin and exported KUBEBUILDER_ASSETS for tests to consume.
Show a summary per file
File Description
.github/workflows/workflow.yaml Reworks the test workflow’s envtest binary setup to use setup-envtest and sets KUBEBUILDER_ASSETS.

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 2

sudo mv kubernetes/server/bin/kube-apiserver /usr/local/kubebuilder/bin/kube-apiserver && \
sudo mv kubernetes/server/bin/kubectl /usr/local/kubebuilder/bin/kubectl && \
sudo mv etcd-v${ETCD_VERSION}-$(go env GOOS)-$(go env GOARCH)/etcd /usr/local/kubebuilder/bin/etcd
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

Copilot AI Apr 9, 2026

Copy link

Choose a reason for hiding this comment

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

go install ...@latest makes the workflow non-reproducible and can unexpectedly change behavior (or break) when a new setup-envtest release is published. Pin setup-envtest to a specific version (or commit) so CI runs are deterministic and easier to audit.

Suggested change
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.20.2

Copilot uses AI. Check for mistakes.

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.

I agree here - it should not be latest.

sudo mv etcd-v${ETCD_VERSION}-$(go env GOOS)-$(go env GOARCH)/etcd /usr/local/kubebuilder/bin/etcd
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
mkdir -p "${HOME}/kubebuilder/bin"
"$HOME/go/bin/setup-envtest" use "${KUBERNETES_VERSION}" --bin-dir "${HOME}/kubebuilder/bin" -p path

Copilot AI Apr 9, 2026

Copy link

Choose a reason for hiding this comment

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

The step assumes the installed binary is at $HOME/go/bin/setup-envtest, but go install can write to a different location when GOPATH/GOBIN are configured differently. Consider invoking setup-envtest via $(go env GOPATH)/bin/setup-envtest or just setup-envtest from PATH to make the workflow more robust across runners.

Suggested change
"$HOME/go/bin/setup-envtest" use "${KUBERNETES_VERSION}" --bin-dir "${HOME}/kubebuilder/bin" -p path
"$(go env GOPATH)/bin/setup-envtest" use "${KUBERNETES_VERSION}" --bin-dir "${HOME}/kubebuilder/bin" -p path

Copilot uses AI. Check for mistakes.

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.

+1

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c669ceb26e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +64 to +65
"$HOME/go/bin/setup-envtest" use "${KUBERNETES_VERSION}" --bin-dir "${HOME}/kubebuilder/bin" -p path
echo "KUBEBUILDER_ASSETS=${HOME}/kubebuilder/bin" >> "$GITHUB_ENV"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Export setup-envtest output path as KUBEBUILDER_ASSETS

setup-envtest use ... -p path prints the version-specific directory that actually contains kube-apiserver, etcd, and kubectl (the tool’s README explicitly says to use -p path to get the directory). This step discards that output and sets KUBEBUILDER_ASSETS to ${HOME}/kubebuilder/bin, which is only the store root; envtest then resolves binaries as ${KUBEBUILDER_ASSETS}/<name> and will not search nested k8s/<version-platform>/ folders, so the make test job will fail when starting envtest.

Useful? React with 👍 / 👎.

@JaydipGabani JaydipGabani 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.

ci is failing because of fetching latest envtest -

go: sigs.k8s.io/controller-runtime/tools/setup-envtest@latest: sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20260405152528-6210f847b2c1 requires go >= 1.26.0 (running go 1.25.8; GOTOOLCHAIN=local)

sudo mv kubernetes/server/bin/kube-apiserver /usr/local/kubebuilder/bin/kube-apiserver && \
sudo mv kubernetes/server/bin/kubectl /usr/local/kubebuilder/bin/kubectl && \
sudo mv etcd-v${ETCD_VERSION}-$(go env GOOS)-$(go env GOARCH)/etcd /usr/local/kubebuilder/bin/etcd
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

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.

I agree here - it should not be latest.

sudo mv etcd-v${ETCD_VERSION}-$(go env GOOS)-$(go env GOARCH)/etcd /usr/local/kubebuilder/bin/etcd
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
mkdir -p "${HOME}/kubebuilder/bin"
"$HOME/go/bin/setup-envtest" use "${KUBERNETES_VERSION}" --bin-dir "${HOME}/kubebuilder/bin" -p path

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.

+1

Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
@sozercan
sozercan force-pushed the codex/fix-unverified-binary-downloads-in-ci-workflow branch from c669ceb to 3de6044 Compare April 21, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants