Skip to content

fix: allow 'build'/'unit-tests'/'validate-csv' make targets to work on non-linux machines - #2839

Open
cdesiniotis wants to merge 1 commit into
NVIDIA:mainfrom
cdesiniotis:fix-unit-test-make-target
Open

fix: allow 'build'/'unit-tests'/'validate-csv' make targets to work on non-linux machines#2839
cdesiniotis wants to merge 1 commit into
NVIDIA:mainfrom
cdesiniotis:fix-unit-test-make-target

Conversation

@cdesiniotis

@cdesiniotis cdesiniotis commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Description

make build / make unit-tests fails with the below error:

package github.com/NVIDIA/gpu-operator/cmd/nvidia-validator
        imports github.com/cyphar/filepath-securejoin/pathrs-lite: build constraints exclude all Go files in /Users/cdesiniotis/git/gpu-operator/vendor/github.com/cyphar/filepath-securejoin/pathrs-lite
make: *** [build] Error 1

This PR moves the linux-only logic to its own build-tagged file, with a stub for other platforms.

This PR also updates our Makefile so that GOOS=linux is not configured by default. This reduces friction when running other make targets on non-linux machines. For example, the validate-csv target would fail prior to this commit with the following error message:

    CGO_ENABLED=0 GOOS=linux \
                    go build -ldflags "-s -w -X github.com/NVIDIA/gpu-operator/internal/info.gitCommit=9aa8cc642 -X github.com/NVIDIA/gpu-operator/internal/info.version=v26.7.0"  github.com/NVIDIA/gpu-operator/cmd/gpuop-cfg
    ./gpuop-cfg validate csv --input=./bundle/manifests/gpu-operator-certified.clusterserviceversion.yaml
    ./gpuop-cfg: ./gpuop-cfg: cannot execute binary file
    make: *** [validate-csv] Error 126

This change should not affect our GHA jobs as they all run on linux runners, and therefore, GOOS should be set to linux there.

Checklist

  • No secrets, sensitive information, or unrelated changes
  • Lint checks passing (make lint)
  • Generated assets in-sync (make validate-generated-assets)
  • Go mod artifacts in-sync (make validate-modules)
  • Test cases are added for new code paths

Testing

$ make build
go build -ldflags "-s -w -X github.com/NVIDIA/gpu-operator/internal/info.gitCommit=caf720fd0 -X github.com/NVIDIA/gpu-operator/internal/info.version=v26.7.0" ./...

$ echo $?
0

$ make unit-tests
go build -ldflags "-s -w -X github.com/NVIDIA/gpu-operator/internal/info.gitCommit=caf720fd0 -X github.com/NVIDIA/gpu-operator/internal/info.version=v26.7.0" ./...
go list -f {{.Dir}} github.com/NVIDIA/gpu-operator/... | grep -v /tests/e2e \
                | xargs go test -v -coverprofile=coverage.out
. . .

$ echo $?
0

@cdesiniotis cdesiniotis self-assigned this Aug 31, 2026
@cdesiniotis cdesiniotis changed the title fix: allow 'build' / 'unit-tests' make target to work on non-linux machines fix: allow 'build'/'unit-tests' make targets to work on non-linux machines Aug 31, 2026
@cdesiniotis
cdesiniotis marked this pull request as draft August 31, 2026 17:06
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR replaces the shared host nvidia-smi resolver with Linux-specific resolution and a non-Linux unsupported-platform stub. The Linux resolver searches predefined host paths and accepts only regular, non-empty, executable files. Linux tests cover precedence, symlinks, WSL paths, invalid files, and missing executables. The previous resolver, dependency, search-path declaration, and shared test are removed.

Merge Risk: 🔴 Critical · up to caf72

Linux builds and unit-test targets cannot compile because the new platform-specific code references an undefined package identifier, so the PR is not merge-ready until that import is added.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: b2310563-779b-4321-a818-e6b1e76d677f

📥 Commits

Reviewing files that changed from the base of the PR and between e6bac63 and caf720f.

📒 Files selected for processing (5)
  • cmd/nvidia-validator/main.go
  • cmd/nvidia-validator/main_test.go
  • cmd/nvidia-validator/resolve_linux.go
  • cmd/nvidia-validator/resolve_linux_test.go
  • cmd/nvidia-validator/resolve_unsupported.go
💤 Files with no reviewable changes (2)
  • cmd/nvidia-validator/main_test.go
  • cmd/nvidia-validator/main.go

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.

// the privileged validator never execs a bogus binary from a non-standard path.
func resolveHostNvidiaSMI(hostRootCtrPath string) (string, error) {
for _, nvidiaSMIPath := range hostNvidiaSMISearchPaths {
f, err := pathrs.OpenInRoot(hostRootCtrPath, nvidiaSMIPath)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- resolve_linux.go ---'
cat -n cmd/nvidia-validator/resolve_linux.go
printf '%s\n' '--- module declarations ---'
rg -n 'go-pathrs|pathrs|^module ' go.mod go.sum cmd internal controllers 2>/dev/null | head -120
printf '%s\n' '--- scoped repository guidance ---'
find /tmp/coderabbit-repo-knowledge/nvidia-gpu-operator-eed98df4 -maxdepth 2 -type f -name '*.md' -print

Repository: NVIDIA/gpu-operator

Length of output: 3506


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- go.mod dependency context ---'
sed -n '28,48p' go.mod
printf '%s\n' '--- existing pathrs caller ---'
cat -n internal/driver/hostsmi.go
printf '%s\n' '--- pathrs references and local module metadata ---'
rg -n 'OpenInRoot|cyphar.com/go-pathrs|github.com/cyphar/filepath-securejoin/pathrs-lite' --glob '*.go' --glob 'go.mod' --glob 'go.sum' .
if go env GOMODCACHE >/dev/null 2>&1; then
  cache="$(go env GOMODCACHE)"
  find "$cache" -path '*go-pathrs*' -o -path '*filepath-securejoin*' 2>/dev/null | head -40
fi

Repository: NVIDIA/gpu-operator

Length of output: 10179


Import the pathrs package.

Line 42 references an undefined identifier. Add pathrs "github.com/cyphar/filepath-securejoin/pathrs-lite" so Linux builds compile.

🧰 Tools
🪛 GitHub Check: config-checks / validate-csv

[failure] 42-42:
undefined: pathrs

🪛 GitHub Check: config-checks / validate-helm-values

[failure] 42-42:
undefined: pathrs

Source: Linters/SAST tools

@cdesiniotis
cdesiniotis force-pushed the fix-unit-test-make-target branch from caf720f to 9aa8cc6 Compare August 31, 2026 17:08
@cdesiniotis
cdesiniotis marked this pull request as ready for review August 31, 2026 17:09
@cdesiniotis cdesiniotis changed the title fix: allow 'build'/'unit-tests' make targets to work on non-linux machines fix: allow 'build'/'unit-tests'/'validate-csv' make targets to work on non-linux machines Aug 31, 2026
@cdesiniotis
cdesiniotis force-pushed the fix-unit-test-make-target branch 2 times, most recently from 15faf78 to 09039be Compare August 31, 2026 20:11
…hines

Signed-off-by: Christopher Desiniotis <cdesiniotis@nvidia.com>

do not default to GOOS=linux in Makefile

This reduces friction for running make targets on non-linux machines.
For example, the `validate-csv` target would fail prior to this commit
with the following error message:

```
CGO_ENABLED=0 GOOS=linux \
                go build -ldflags "-s -w -X github.com/NVIDIA/gpu-operator/internal/info.gitCommit=9aa8cc642 -X github.com/NVIDIA/gpu-operator/internal/info.version=v26.7.0"  github.com/NVIDIA/gpu-operator/cmd/gpuop-cfg
./gpuop-cfg validate csv --input=./bundle/manifests/gpu-operator-certified.clusterserviceversion.yaml
./gpuop-cfg: ./gpuop-cfg: cannot execute binary file
make: *** [validate-csv] Error 126
```

This change should not affect our GHA jobs as they all run on
linux runners, and therefore, GOOS should be set to linux there.

Signed-off-by: Christopher Desiniotis <cdesiniotis@nvidia.com>
@cdesiniotis
cdesiniotis force-pushed the fix-unit-test-make-target branch from 09039be to d271652 Compare August 31, 2026 20:14
@abrarshivani

Copy link
Copy Markdown
Contributor

Our current CI runs only on Linux, so it will not catch a future linux only dependency being introduced back into shared code. Can we add a non linux build check for this case? For example, GOOS=darwin CGO_ENABLED=0 go build ./... will help guard against that regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants