Skip to content

Remove k8s.io/kubernetes from kubectl library import path#4756

Draft
avalcepina wants to merge 1 commit into
argoproj:masterfrom
avalcepina:remove-k8s-kubernetes-from-kubectl-lib-path
Draft

Remove k8s.io/kubernetes from kubectl library import path#4756
avalcepina wants to merge 1 commit into
argoproj:masterfrom
avalcepina:remove-k8s-kubernetes-from-kubectl-lib-path

Conversation

@avalcepina

Copy link
Copy Markdown

Summary

Downstream projects that import pkg/kubectl-argo-rollouts/cmd/* (e.g. promote, abort, restart, retry) previously pulled in k8s.io/kubernetes transitively via utils/replicaset. That causes govulncheck to report GO-2025-3547 and GO-2025-3521 on the kubernetes monorepo even for client-side library usage where those kube-apiserver findings are not exploitable.

This change inlines the small helpers those library packages need into a new utils/k8sutil package:

  • ComputeHash (legacy hash compatibility with upstream controller)
  • ReplicaSetsByCreationTimestamp
  • FilterActiveReplicaSets
  • PodTemplate defaulting used by PodTemplateEqualIgnoreHash

After this change, the kubectl command packages no longer depend on k8s.io/kubernetes. The rollouts controller continues to import the kubernetes monorepo directly (unchanged).

Motivation

circleci/k8s-release-agent imports the kubectl-argo-rollouts command packages as a Go library. After upgrading to argo-rollouts v1.9.0 (PR #791), govulncheck ./... still reports two unfixable k8s.io/kubernetes findings (GO-2025-3547, GO-2025-3521). Those advisories list all versions as affected with no upstream fix; removing the transitive import path is the practical remediation for library consumers.

Verification

  • go test ./utils/k8sutil/... ./utils/replicaset/...
  • go list -deps ./pkg/kubectl-argo-rollouts/cmd/{promote,abort,restart,retry,undo} → no k8s.io/kubernetes packages
  • govulncheck on the kubectl library packages → GO-2025-3547 / GO-2025-3521 no longer reported

Test plan

  • Unit tests for utils/k8sutil and utils/replicaset
  • CI unit/integration test suite
  • Confirm no behavior change in promote/abort/restart/retry paths (hash compatibility preserved)

Downstream projects that import pkg/kubectl-argo-rollouts/cmd/* (promote,
abort, restart, retry) previously pulled in k8s.io/kubernetes transitively
via utils/replicaset. That caused govulncheck to report GO-2025-3547 and
GO-2025-3521 even though those findings are not exploitable in client-side
library usage.

Inline the small controller helpers (ComputeHash, ReplicaSetsByCreationTimestamp,
FilterActiveReplicaSets) and PodTemplate defaulting in utils/k8sutil so the
kubectl command packages no longer depend on the kubernetes monorepo. The
rollouts controller continues to use k8s.io/kubernetes directly.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Published E2E Test Results

  4 files    4 suites   3h 48m 8s ⏱️
120 tests 105 ✅  7 💤  8 ❌
492 runs  452 ✅ 28 💤 12 ❌

For more details on these failures, see this check.

Results for commit dc3eceb.

@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.00%. Comparing base (017676b) to head (dc3eceb).

Files with missing lines Patch % Lines
utils/k8sutil/defaults.go 76.66% 3 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4756      +/-   ##
==========================================
- Coverage   85.01%   85.00%   -0.02%     
==========================================
  Files         164      166       +2     
  Lines       18989    19036      +47     
==========================================
+ Hits        16144    16182      +38     
- Misses       1995     1999       +4     
- Partials      850      855       +5     

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Published Unit Test Results

2 472 tests   2 472 ✅  3m 21s ⏱️
  130 suites      0 💤
    1 files        0 ❌

Results for commit dc3eceb.

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.

1 participant