Repository navigation
Split API into a standalone Go module - #2882
aryangorwade wants to merge 8 commits into
Conversation
470d8a1 to
0acdb89
Compare
| github.com/Masterminds/sprig/v3 v3.3.0 | ||
| github.com/NVIDIA/go-nvlib v0.12.0 | ||
| github.com/NVIDIA/k8s-kata-manager v0.2.3 | ||
| github.com/NVIDIA/gpu-operator/api v0.2603.3 |
There was a problem hiding this comment.
Should this be changed to a psuedo-verison v0.0.0-00010101000000-000000000000 that is not updated in any version-bump PRs? If changes were made to /api after say release 26.03.3, but those changes are not part of any current release; this could incorrectly point to a stale older API version.
A problem is that this would result in a built image's embedded binary reporting a psuedo-version and failing CVE scans. That is what currently happens with the gpu-operator and most of our Go products anyways
There was a problem hiding this comment.
A problem is that this would result in a built image's embedded binary reporting a psuedo-version and failing CVE scans.
I'm not sure setting a version for github.com/NVIDIA/gpu-operator/api has any effect on the version embedded for the gpu-operator binary. I think a pseudo-version will be embedded for the main binary regardless of what version a dependency is declared as.
There was a problem hiding this comment.
Makes sense. #428 would only apply to the main binary which is the gpu operator.
There was a problem hiding this comment.
@aryangorwade what is the plan for actually merging this PR ? what version would we set here ?
There was a problem hiding this comment.
This should be v0.0.0-00010101000000-000000000000.
There was a problem hiding this comment.
could it also be the version of the next potential release ?
There was a problem hiding this comment.
It could but that would tie back to this issue above:
If changes were made to /api after say release 26.03.3, but those changes are not part of any current release; this could incorrectly point to a stale older API version.
Say yesterday we released v26.03.3 of api and operator. But then today we merged changes to /api on main. The code would now incorrectly point to a stale api version of v26.03.3 until the next release. To avoid problems like this, it is better to just leave it as the zero version, v0.0.0-00010101000000-000000000000.
This change has not been made yet; the code still says github.com/NVIDIA/gpu-operator/api v0.2603.3.
There was a problem hiding this comment.
This makes sense, thanks for clarifying
📝 WalkthroughWalkthroughThe repository now contains a separate Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to A release PR can bypass API-tag collision validation by using a different title, risking an invalid release. The lint suppression can also hide new deprecated API usage. Resolve these checks before merge. ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
🟡 Other comments (1)
.golangci.yml-30-30 (1)
30-30: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winLimit the SA1019 exclusion to the known compatibility sites.
This rule has no path restriction. Both lint commands scan root and API packages with this configuration, so any matching
.ConfigMapNameor.Namediagnostic outside the compatibility sites will be silently excluded. Restore a path restriction or narrow the exclusion to the affected legacy types so CI reports reintroduced deprecated uses.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: QUIET
Plan: Enterprise
Run ID: c6cb07c3-751f-40f4-a465-f56bb1f4e5ad
⛔ Files ignored due to path filters (23)
api/go.sumis excluded by!**/*.sumvendor/github.com/NVIDIA/gpu-operator/api/image/image.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1/clusterpolicy_types.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1/groupversion_info.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1/zz_generated.deepcopy.gois excluded by!vendor/**,!**/zz_generated.*.govendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/gpucluster_types.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/groupversion_info.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/nvidiadriver_types.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/zz_generated.deepcopy.gois excluded by!vendor/**,!**/zz_generated.*.govendor/github.com/NVIDIA/gpu-operator/api/versioned/clientset.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/versioned/scheme/doc.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/versioned/scheme/register.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/clusterpolicy.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/doc.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/generated_expansion.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/nvidia_client.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/doc.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/generated_expansion.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/gpucluster.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/nvidia_client.gois excluded by!vendor/**vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/nvidiadriver.gois excluded by!vendor/**vendor/k8s.io/client-go/discovery/fake/discovery.gois excluded by!vendor/**vendor/modules.txtis excluded by!vendor/**
📒 Files selected for processing (36)
.common-ci.yml.github/dependabot.yml.github/workflows/api-post-tag-validation.yaml.github/workflows/api-release-checks.yaml.golangci.yml.nvidia-ci.ymlMakefileapi/go.modapi/image/image.goapi/image/imagepath_validation_test.goapi/nvidia/v1alpha1/nvidiadriver_types.gocontrollers/clusterpolicy_controller.gocontrollers/clusterpolicy_controller_test.gocontrollers/nodelabeling_controller.gocontrollers/nodelabeling_controller_test.gocontrollers/object_controls_test.gocontrollers/upgrade_controller.gocontrollers/upgrade_controller_test.godocker/Dockerfile.develgo.modhack/validate-api-version-unpublished.shhack/validate-published-api-module.shhack/validate-shared-dependencies.shinternal/consts/consts.gointernal/nvidiadriver/nvidiadriver.gointernal/nvidiadriver/nvidiadriver_errors_test.gointernal/nvidiadriver/nvidiadriver_test.gointernal/state/configurable_state.gointernal/state/dra_driver.gointernal/state/driver.gointernal/state/driver_manifest_test.gointernal/state/driver_test.gointernal/state/nodepool.gointernal/state/nodepool_test.gointernal/validator/validator_test.gotools/generate-third-party-notices.sh
💤 Files with no reviewable changes (1)
- internal/consts/consts.go
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.
| contains(github.event.pull_request.title, 'operator') && | ||
| contains(github.event.pull_request.title, 'version') && | ||
| contains(github.event.pull_request.title, 'bump') |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,120p' .github/workflows/api-release-checks.yaml
rg -n --glob '!vendor/**' 'validate-api-version-unpublished|API Release Checks|operator.*version.*bump|OPERATOR_VERSION|api/v' .github Makefile hack versions.mk . 2>/dev/null | head -240Repository: NVIDIA/gpu-operator
Length of output: 10771
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- validator ---'
sed -n '1,220p' hack/validate-api-version-unpublished.sh
printf '%s\n' '--- make/version definitions ---'
sed -n '220,265p' Makefile
sed -n '1,180p' versions.mk
printf '%s\n' '--- release/version references ---'
rg -n -i --glob '!vendor/**' --glob '!third_party/**' '(version bump|bump.*version|release.*version|operator.*version|api.*tag|unpublished|pull request.*title|title.*operator)' .github README.md CONTRIBUTING.md AGENTS.md PROJECT Makefile hack versions.mk 2>/dev/null | head -300
printf '%s\n' '--- release workflow/template filenames ---'
git ls-files '.github' | rg -i '(release|pull|pr|version|api)'Repository: NVIDIA/gpu-operator
Length of output: 15870
🤖 get_repo_knowledge executed:
get_repo_knowledge NVIDIA/gpu-operator /tmp/coderabbit-repo-knowledge/nvidia-gpu-operator-eed98df4/conventions
Length of output: 4401
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- pull request template ---'
sed -n '1,220p' .github/PULL_REQUEST_TEMPLATE.md
printf '%s\n' '--- contributing release guidance ---'
sed -n '45,75p' CONTRIBUTING.md
printf '%s\n' '--- API post-tag validation workflow ---'
sed -n '1,110p' .github/workflows/api-post-tag-validation.yaml
printf '%s\n' '--- release workflow triggers and version inputs ---'
sed -n '1,75p' .github/workflows/release.yaml
sed -n '1,55p' .github/workflows/release-rc-assets.yamlRepository: NVIDIA/gpu-operator
Length of output: 8575
Run the API-tag check for version changes.
If a PR changes the API module version but its title does not contain all three required substrings, GitHub skips api-version-unpublished. The validator then does not check whether api/<version> already exists, so a title such as Release v25.3.0 can bypass this release check. The PR template does not require the current title format.
Gate the job on changed API version metadata, or use a required release signal that cannot be omitted by changing the title.
Relocate shared image path logic and NVIDIADriver constants so api/ no longer imports root internal packages ahead of becoming a standalone Go module. Signed-off-by: Aryan Gorwade <agorwade@nvidia.com>
Give API consumers a Go-compatible versioned module while keeping root development builds pinned to the local API source. Signed-off-by: Aryan Gorwade <agorwade@nvidia.com>
Signed-off-by: Aryan Gorwade <agorwade@nvidia.com>
Fail CI when direct dependencies shared by the root and API modules use different versions. Signed-off-by: Aryan Gorwade <agorwade@nvidia.com>
Verify operator and API tags share a commit and that released binaries record the independently downloadable API module version. Signed-off-by: Aryan Gorwade <agorwade@nvidia.com>
Have Dependabot update shared root and API dependencies together while preserving grouped Kubernetes upgrades. Signed-off-by: Aryan Gorwade <agorwade@nvidia.com>
Run the unpublished-tag check for pull requests whose titles identify an operator version bump. Signed-off-by: Aryan Gorwade <agorwade@nvidia.com>
Skip internal pipelines for API-only tags and prevent them from reaching Nspect or NGC publishing jobs. Signed-off-by: Aryan Gorwade <agorwade@nvidia.com>
0acdb89 to
dc78578
Compare
| $(if $(SKIP_REGISTRY),--skip-registry) \ | ||
| --gpu-operator-version "$(IMAGE_TAG)" | ||
|
|
||
| validate-generated-assets: manifests generate generate-clientset sync-crds |
There was a problem hiding this comment.
I think with replace github.com/NVIDIA/gpu-operator/api => ./api plus the checked-in vendor/, root packages compile against vendor/github.com/NVIDIA/gpu-operator/api/..., not ./api. From the PR head, go list -f '{{.Dir}}' github.com/NVIDIA/gpu-operator/api/nvidia/v1 resolves to the vendor path.
I think we should have generate, generate-clientset and manifests depend on update-vendor, or add vendor to the diff here, so regenerating API code always leaves vendor/ consistent. maybe we can add a short not in AGENTS.md / CONTRIBUTING.md that api/ changes need make update-vendor.
There was a problem hiding this comment.
generate: can change/api; makes sense to runupdate-vendorat the end of this commandgenerate-clientset: same as above. Both of these read directly from/apiand can change itmanifests: reads from/vendoredand/api. The first step of this command should beupdate-vendor.
This could run go mod vendor up to three times and cause possible race conditions. The solution is to add a validate-vendor command that generates /vendor into a temporary directory and diffs against /api (unique tmp directories per invocation). This command will substitute update-vendor in the commands described above.
Some others that need this validation are:
cmd-*: prerequisite checkgoimports: postprocess checkbuild-image: prerequisite check on the hostrun: prerequisite checklint: prerequisite checkbuild: postprocess check (would affectunit-testandcoverage)validate-modules: rewrite to usevalidate-vendor
Ideally only one command should run go mod vendor. I think this should be validate-generated-assets since it already writes to /api. What do you think?
There was a problem hiding this comment.
yeah I think validate-generated-assets makes sense to me.
| API_MODULE="github.com/NVIDIA/gpu-operator/api" | ||
| UPSTREAM_REPOSITORY="${1:-https://github.com/NVIDIA/gpu-operator.git}" | ||
|
|
||
| api_version="$(go list -m -f '{{.Version}}' "${API_MODULE}")" |
There was a problem hiding this comment.
do we also need to check if the api version maps to an operator version, basically validate the mapping here as well ? like we do inhack/validate-published-api-module.sh , so that we catch the issue before an image is published ?
There was a problem hiding this comment.
This is the PR/pre-tag check, so the commit does not have operator version or api version tags at this point. Should it compare the operator version in versions.mk to the API version derived from root go.mod?
There was a problem hiding this comment.
Yeah that is what I was thinking, do you see any issues with that ?
There was a problem hiding this comment.
That should be a good addition to this check. I will add it
There was a problem hiding this comment.
@kvalliyurnatt Adding github.com/NVIDIA/gpu-operator/api v0.0.0-00010101000000-000000000000 in root go.mod breaks this proposed check.
It also breaks the existing comparison (checking if root go.mod version tag exists upstream). We will have to change it to read version from versions.mk. Similar parts of of hack/validate-published-api-module.sh will also have to be reworked because of this.
There was a problem hiding this comment.
ooh I see, I missed that. I guess we can leave this as is then
Description
This is a PR splitting
/apiinto a standalone module, this would serve to fix GPU Operator versioning issues (Go supportsv0.x.yandv1.x.y).This architectural split involves:
api/into/apito avoid circular importsgo.modandgo.sum; rootgo.modreferences this module nowCI checks introduced:
Changes to CI pipeline:
.nvidia-ci.yamland.common-ci.yamlto ensure that tagging a release commit with operator and api tags does not cause a separate release process to trigger for theapitag in addition to the operator tagDependabot changes:
dependabot.yamlusinggroup-by: dependency-nameand across-directorypattern to update each shared dependency between both modules in one PR (one PR per dependency; for both modules). Note that groups such ask8s.io/*can be created, resulting in one cross-directory PR for all deps underk8s.io/*.Checklist
make lint)make validate-generated-assets)make validate-modules)Testing
Tested building & deploying the operator on a cluster with some test workloads. Tested Makefile commands.