Skip to content

CNF-23385: mockgen deprecated: use uber-go/mock instead - #157

Open
sebrandon1 wants to merge 1 commit into
openshift:mainfrom
sebrandon1:mockgen_deprecation
Open

CNF-23385: mockgen deprecated: use uber-go/mock instead#157
sebrandon1 wants to merge 1 commit into
openshift:mainfrom
sebrandon1:mockgen_deprecation

Conversation

@sebrandon1

@sebrandon1 sebrandon1 commented Nov 13, 2025

Copy link
Copy Markdown
Member

https://github.com/golang/mock is marked as archived as of June 27, 2023. They recommend using go.uber.org/mock.

This PR attempts to change the dependency to one that is maintained.

Tracking issue: redhat-best-practices-for-k8s/telco-bot#45

Summary by CodeRabbit

  • Chores
    • Updated Go toolchain version to a compatible release.
    • Migrated testing infrastructure to newer compatible libraries.
    • Refreshed multiple project dependencies including cloud provider modules and Kubernetes components to latest available versions.

@openshift-ci
openshift-ci Bot requested review from RadekManak and nrb November 13, 2025 17:17
@openshift-ci

openshift-ci Bot commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign joelspeed for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 18, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 21, 2025
@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

@coderabbitai

coderabbitai Bot commented Feb 27, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Swapped mock tooling from github.com/golang/mock to go.uber.org/mock: updated go.mod, tools.go, //go:generate directive, regenerated mock(s) with minor mock type/signature differences, and adjusted test imports to the new gomock module. No behavioral code changes.

Changes

Mocking dependency and generated mocks

Layer / File(s) Summary
Dependency manifest
go.mod
Replaced github.com/golang/mock v1.6.0 with go.uber.org/mock v0.6.0; multiple other dependency versions/timestamps updated.
Tooling import
tools.go
Tool import changed from _ "github.com/golang/mock/mockgen"_ "go.uber.org/mock/mockgen".
Generate directive
pkg/client/client.go
//go:generate updated to call go.uber.org/mock/mockgen for ./mock/client_generated.go.
Generated mocks
pkg/client/mock/client_generated.go
Regenerated mock file: gomock import path updated, added isgomock struct{} fields on exported mocks, recorder parameter types changed from interface{} to any, and generation header comment added.
Test imports
pkg/actuators/machine/..._test.go
Test imports updated from github.com/golang/mock/gomockgo.uber.org/mock/gomock across multiple test files; test logic unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: migrating from the deprecated golang/mock library to the maintained go.uber.org/mock library, which is reflected throughout the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The PR contains no Ginkgo tests. The repository uses standard Go testing package with Gomega assertions, not Ginkgo. The check is not applicable to this PR.
Test Structure And Quality ✅ Passed Custom check is not applicable. This PR only migrates mock framework imports; the repository uses standard Go testing (testing.T), not Ginkgo.
Microshift Test Compatibility ✅ Passed PR contains no new Ginkgo e2e tests. Changes are solely a dependency migration (golang/mock → go.uber.org/mock) with import updates in existing test files.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR is a dependency migration (golang/mock to uber-go/mock) with no new Ginkgo e2e tests. All test files use standard Go testing (testing.T), not Ginkgo. The check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR only updates mock library dependencies and test imports (golang/mock → go.uber.org/mock). No deployment manifests, operator code, controllers, or scheduling constraints are modified.
Ote Binary Stdout Contract ✅ Passed PR only updates mock dependency imports in test files and go.mod. No main(), init(), or process-level code changes. No new stdout writes introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Check not applicable. PR migrates mock dependencies without adding new Ginkgo e2e tests. Only import path and dependency version updates present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

🧹 Nitpick comments (1)
pkg/client/mock/client_generated.go (1)

71-443: Normalize recorder argument types in generated mocks from mixed interface{} and any to consistent any.

The mock file shows three recorder methods using interface{} (AllocateHosts, DescribeHosts, ReleaseHosts) while most others use any. Since both are equivalent in Go 1.18+, normalizing to any across all generated recorder methods will reduce noise in future mock regeneration diffs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/client/mock/client_generated.go` around lines 71 - 443, Recorder methods
AllocateHosts, DescribeHosts, and ReleaseHosts use interface{} for their
parameter types while other recorder methods use any; update the signatures in
MockClientMockRecorder so the parameter type is any (replace interface{} with
any) for AllocateHosts, DescribeHosts, and ReleaseHosts to normalize generated
mock recorder argument types (match methods like DescribeImages, DescribeVpcs,
etc.).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/client/mock/client_generated.go`:
- Around line 71-443: Recorder methods AllocateHosts, DescribeHosts, and
ReleaseHosts use interface{} for their parameter types while other recorder
methods use any; update the signatures in MockClientMockRecorder so the
parameter type is any (replace interface{} with any) for AllocateHosts,
DescribeHosts, and ReleaseHosts to normalize generated mock recorder argument
types (match methods like DescribeImages, DescribeVpcs, etc.).

ℹ️ Review info

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between bcf58df and 7b46ac5.

⛔ Files ignored due to path filters (23)
  • go.sum is excluded by !**/*.sum
  • vendor/github.com/golang/mock/CONTRIBUTORS is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/golang/mock/mockgen/reflect.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/golang/mock/mockgen/version.1.11.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/AUTHORS is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/LICENSE is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/gomock/call.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/gomock/callset.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/gomock/controller.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/gomock/doc.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/gomock/matchers.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/gomock/string.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/archive.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/deprecated.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/generic.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/gob.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/mockgen.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/model/model.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/model/model_gotypes.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/package_mode.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/parse.go is excluded by !**/vendor/**, !vendor/**
  • vendor/go.uber.org/mock/mockgen/version.go is excluded by !**/vendor/**, !vendor/**
  • vendor/modules.txt is excluded by !**/vendor/**, !vendor/**
📒 Files selected for processing (10)
  • go.mod
  • pkg/actuators/machine/actuator_test.go
  • pkg/actuators/machine/controller_test.go
  • pkg/actuators/machine/instances_test.go
  • pkg/actuators/machine/loadbalancers_test.go
  • pkg/actuators/machine/machine_scope_test.go
  • pkg/actuators/machine/reconciler_test.go
  • pkg/client/client.go
  • pkg/client/mock/client_generated.go
  • tools.go

@sebrandon1
sebrandon1 force-pushed the mockgen_deprecation branch from 32eccd5 to b8ab78b Compare March 20, 2026 19:44
@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 21, 2026
@sebrandon1
sebrandon1 force-pushed the mockgen_deprecation branch from b8ab78b to 27e5b25 Compare April 30, 2026 19:04
@openshift-ci openshift-ci Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 30, 2026
@sebrandon1 sebrandon1 changed the title mockgen deprecated: use uber-go/mock instead CNF-23385: mockgen deprecated: use uber-go/mock instead Apr 30, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 30, 2026
@openshift-ci-robot

openshift-ci-robot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

@sebrandon1: This pull request references CNF-23385 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

https://github.com/golang/mock is marked as archived as of June 27, 2023. They recommend using go.uber.org/mock.

This PR attempts to change the dependency to one that is maintained.

Tracking issue: redhat-best-practices-for-k8s/telco-bot#45

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@sebrandon1
sebrandon1 force-pushed the mockgen_deprecation branch from 27e5b25 to 1924d5d Compare May 7, 2026 20:59

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@go.mod`:
- Line 66: The go.mod currently pulls github.com/moby/spdystream v0.5.0
(indirect) via Kubernetes modules; update the Kubernetes module versions (e.g.,
k8s.io/apimachinery, k8s.io/client-go, k8s.io/api, k8s.io/component-base) to a
release that vendors spdystream v0.5.1 or later so the indirect dependency is
upgraded; edit go.mod to bump those k8s module versions (and run go get / go mod
tidy) until github.com/moby/spdystream resolves to v0.5.1+, then verify with go
list -m all that spdystream is v0.5.1 or newer.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: cf552b14-f9f8-4a6c-ae94-5b30c46b7b9c

📥 Commits

Reviewing files that changed from the base of the PR and between b8ab78b and 1924d5d.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod

Comment thread go.mod Outdated
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/moby/spdystream v0.5.0 // indirect

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check for spdystream vulnerability details and dependency chain

echo "=== Vulnerability details ==="
gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: GO, package: "github.com/moby/spdystream") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
      firstPatchedVersion {
        identifier
      }
    }
  }
}'

echo -e "\n=== Dependency chain for moby/spdystream ==="
go mod graph | grep moby/spdystream

Repository: openshift/machine-api-provider-aws

Length of output: 480


🏁 Script executed:

# Read the go.mod file to see the full context around line 66 and identify dependencies
cat -n go.mod | head -80 | tail -30

Repository: openshift/machine-api-provider-aws

Length of output: 2104


🏁 Script executed:

# Check go.sum for spdystream entries
rg "moby/spdystream" go.sum

Repository: openshift/machine-api-provider-aws

Length of output: 60


🏁 Script executed:

# Search for which dependency brings in spdystream
rg "moby/spdystream" go.mod

Repository: openshift/machine-api-provider-aws

Length of output: 125


🏁 Script executed:

# Search for which direct dependency might require spdystream
# Check the requires section and common k8s/container deps
head -50 go.mod | grep -E "^require|^\s+k8s\.io|^\s+github\.com/(kubernetes|moby|containerd|docker)"

Repository: openshift/machine-api-provider-aws

Length of output: 304


🏁 Script executed:

# Look for any replace directives that might affect spdystream
rg "replace" go.mod

Repository: openshift/machine-api-provider-aws

Length of output: 60


🏁 Script executed:

# Search source code for any direct imports of spdystream or related packages
rg "github.com/moby/spdystream|spdystream" --type go .

Repository: openshift/machine-api-provider-aws

Length of output: 6660


🏁 Script executed:

# Check if there are newer Kubernetes module versions available
# and whether they would have spdystream v0.5.1
go list -m -versions k8s.io/apimachinery 2>/dev/null | head -5

Repository: openshift/machine-api-provider-aws

Length of output: 60


🏁 Script executed:

# Check the current version of spdystream that k8s.io/apimachinery v0.34.1 depends on
# by looking at what direct K8s dependency brings it in
# Let's verify the import chain more clearly
rg "k8s.io/apimachinery" go.mod | head -5

Repository: openshift/machine-api-provider-aws

Length of output: 107


🏁 Script executed:

# Search for any constraint or override information in go.mod
cat go.mod | grep -A 5 "^require ("

Repository: openshift/machine-api-provider-aws

Length of output: 552


🏁 Script executed:

# Check if there's information in the repository about upgrade paths
# or if there's any documentation mentioning spdystream or k8s version constraints
find . -name "*.md" -o -name "*.txt" | xargs grep -l "spdystream\|k8s\.io.*version" 2>/dev/null | head -5

Repository: openshift/machine-api-provider-aws

Length of output: 343


🏁 Script executed:

# Check the GitHub releases or tags for k8s.io/apimachinery newer versions
# Since we can't easily get full listing, let's look for any hints in the codebase
# about planned version updates or vendor information
ls -la go.* vendor/ 2>/dev/null | head -20

Repository: openshift/machine-api-provider-aws

Length of output: 1136


Update K8s modules to pull in patched spdystream v0.5.1.

github.com/moby/spdystream v0.5.0 has a HIGH severity denial-of-service vulnerability (GHSA-pc3f-x583-g7j2). This indirect dependency is pulled in by k8s.io/apimachinery (and related K8s modules like k8s.io/client-go, k8s.io/api, k8s.io/component-base), all currently at v0.34.1. Upgrading these K8s modules to a version that includes spdystream v0.5.1 or later will resolve this.

🧰 Tools
🪛 OSV Scanner (2.3.6)

[HIGH] 66-66: github.com/moby/spdystream 0.5.0: SpdyStream: DOS on CRI

(GHSA-pc3f-x583-g7j2)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@go.mod` at line 66, The go.mod currently pulls github.com/moby/spdystream
v0.5.0 (indirect) via Kubernetes modules; update the Kubernetes module versions
(e.g., k8s.io/apimachinery, k8s.io/client-go, k8s.io/api, k8s.io/component-base)
to a release that vendors spdystream v0.5.1 or later so the indirect dependency
is upgraded; edit go.mod to bump those k8s module versions (and run go get / go
mod tidy) until github.com/moby/spdystream resolves to v0.5.1+, then verify with
go list -m all that spdystream is v0.5.1 or newer.

@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

@sebrandon1
sebrandon1 force-pushed the mockgen_deprecation branch from 1924d5d to bd17c27 Compare May 20, 2026 15:23
@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

@sebrandon1

Copy link
Copy Markdown
Member Author

/retest-required

@perdasilva

Copy link
Copy Markdown

@sebrandon1 this has been open for wee while now. Is it still relevant?

@perdasilva

Copy link
Copy Markdown

/retest

@sebrandon1
sebrandon1 force-pushed the mockgen_deprecation branch from bd17c27 to edfeeb0 Compare June 26, 2026 18:03
@sebrandon1
sebrandon1 force-pushed the mockgen_deprecation branch from edfeeb0 to 5633935 Compare July 6, 2026 16:15
@sebrandon1
sebrandon1 force-pushed the mockgen_deprecation branch from 5633935 to e461840 Compare July 31, 2026 02:58
@openshift-ci

openshift-ci Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@sebrandon1: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/okd-scos-e2e-aws-ovn e6d9150 link false /test okd-scos-e2e-aws-ovn
ci/prow/images e461840 link true /test images
ci/prow/regression-clusterinfra-aws-ipi-mapi e461840 link false /test regression-clusterinfra-aws-ipi-mapi
ci/prow/verify-deps e461840 link true /test verify-deps
ci/prow/e2e-aws-serial-2of2 e461840 link true /test e2e-aws-serial-2of2
ci/prow/e2e-aws-operator e461840 link true /test e2e-aws-operator
ci/prow/okd-scos-images e461840 link true /test okd-scos-images
ci/prow/goimports e461840 link true /test goimports
ci/prow/unit e461840 link true /test unit
ci/prow/e2e-aws-serial-1of2 e461840 link true /test e2e-aws-serial-1of2
ci/prow/e2e-aws-upgrade e461840 link true /test e2e-aws-upgrade
ci/prow/govet e461840 link true /test govet
ci/prow/e2e-aws e461840 link true /test e2e-aws

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants