Skip to content

Conversation

@lokielse
Copy link
Contributor

Description

This PR optimizes the client code generation process in hack/update-client.sh by replacing go mod vendor with go mod download and leveraging Go's module cache directly.

Changes Made

  • Replaced go mod vendor with go mod download to avoid creating a temporary vendor directory
  • Modified the script to locate k8s.io/code-generator from the Go module cache using go list -m -f '{{.Dir}}'
  • Removed the rm -r vendor cleanup step as vendor directory is no longer created
  • Added inline comments to clarify the new approach

Performance Benefits

This change brings performance improvements to CI pipelines:

  1. Faster Execution: Eliminates the overhead of copying dependencies to a vendor directory. go mod download only ensures dependencies are in the module cache, while go mod vendor requires creating and populating an entire vendor tree.

  2. Reduced I/O Operations: Avoids unnecessary file system operations (creating, copying, and deleting vendor directory with potentially hundreds of files).

  3. Better Cache Utilization: Leverages Go's built-in module cache ($GOMODCACHE), which is typically already populated in CI environments, further reducing download time on subsequent runs.

  4. Disk Space Efficiency: No temporary vendor directory is created and removed during the process, reducing disk I/O pressure.

In local testing, the script executes successfully and generates the same client code as before, confirming functional equivalence with improved efficiency.

Related Issues

N/A

Checklist

  • Self-reviewed
  • Added/updated tests (if needed) - No test changes needed, verified script works correctly
  • Updated CHANGELOG.md (if needed)
  • Updated documentation (if needed) - Inline comments added to script

Breaking Changes

None. This is an internal optimization to the build process with no impact on generated code or public APIs.

Additional Notes

Verification

The modified script has been tested and successfully generates client code:

  • Generated client, lister, and informer code for 3 targets
  • All file headers replaced correctly
  • No changes to generated client code (functionally identical output)
  • git status confirms no vendor directory artifacts left behind

Modern Go Best Practices

This change aligns with modern Go module practices where the module cache is the preferred source of dependencies rather than vendoring, especially for build-time tools.

@enoodle enoodle merged commit 489b9f0 into NVIDIA:main Nov 18, 2025
4 checks passed
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.

2 participants