Skip to content

CCO-837: Replace deprecated golang/mock with go.uber.org/mock#1067

Open
ericahinkleRH wants to merge 5 commits into
openshift:masterfrom
ericahinkleRH:CCO-837
Open

CCO-837: Replace deprecated golang/mock with go.uber.org/mock#1067
ericahinkleRH wants to merge 5 commits into
openshift:masterfrom
ericahinkleRH:CCO-837

Conversation

@ericahinkleRH

@ericahinkleRH ericahinkleRH commented Jul 14, 2026

Copy link
Copy Markdown

Summary

Replaces the deprecated github.com/golang/mock library with the maintained fork go.uber.org/mock.

The golang/mock repository is no longer maintained and officially recommends migrating to go.uber.org/mock:

Update, June 2023: This repo and tool are no longer maintained. Please see go.uber.org/mock for a maintained fork instead.

Changes

  • go.mod: Updated dependency from github.com/golang/mock v1.7.0-rc.1 to go.uber.org/mock v0.6.0
  • Import paths: Updated 27 test files to use go.uber.org/mock/gomock instead of github.com/golang/mock/gomock
  • API compatibility fix: Updated pkg/operator/utils/gcp/utils_test.go to handle gomock API change where InOrder() now expects variadic any parameters
  • Vendor: Updated vendor directory with new mock library

Test Status

✅ All mockgen-related tests pass successfully
❌ Some tests fail due to unrelated blocker: openshift/library-go#2171 (HasSyncedChecker method requirement)

This PR has the same library-go dependency blocker as PR #1066 (CCO-834). Both PRs are waiting for openshift/library-go#2171 to merge before tests can fully pass.

Test Plan

Ran make test - all tests that can run pass. Failures are exclusively from the library-go blocker, not from the mock library migration.

Summary by CodeRabbit

  • Chores

    • Updated core Kubernetes and related platform libraries.
    • Replaced the legacy mocking framework with its maintained successor across tests and generated mocks.
    • Refreshed supporting observability, API, networking, and utility libraries.
  • Tests

    • Preserved existing test coverage and behavior while aligning mock usage with the updated tooling.

ericahinkleRH and others added 5 commits July 10, 2026 13:27
Update Kubernetes dependencies to v0.36.0 and controller-runtime to
v0.24.0. Bump openshift/api for compatibility with APIs removed in
Kubernetes 1.36. Regenerate codegen and apply a temporary library-go
vendor patch for HasSyncedChecker until openshift/library-go#2171 merges.

Assisted-by: Claude
Track the temporary vendor patch for HasSyncedChecker() in deps.diff
as required by the verify-deps check.
Per review feedback from dlom, the library-go vendor patch is not needed.
Using the clean version from go mod vendor instead.
The golang/mock repository is no longer maintained and recommends
migrating to go.uber.org/mock as a maintained fork.

This commit replaces github.com/golang/mock with go.uber.org/mock
across the codebase:
- Updated go.mod dependency from v1.7.0-rc.1 to v0.6.0
- Replaced import paths in 27 test files
- Fixed gomock API compatibility in utils_test.go where InOrder()
  now expects variadic any parameters

Note: Some tests still fail due to the openshift/library-go#2171
dependency (HasSyncedChecker method requirement), which is unrelated
to this mock library migration.

Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 14, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

@ericahinkleRH: This pull request references CCO-837 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:

Summary

Replaces the deprecated github.com/golang/mock library with the maintained fork go.uber.org/mock.

The golang/mock repository is no longer maintained and officially recommends migrating to go.uber.org/mock:

Update, June 2023: This repo and tool are no longer maintained. Please see go.uber.org/mock for a maintained fork instead.

Changes

  • go.mod: Updated dependency from github.com/golang/mock v1.7.0-rc.1 to go.uber.org/mock v0.6.0
  • Import paths: Updated 27 test files to use go.uber.org/mock/gomock instead of github.com/golang/mock/gomock
  • API compatibility fix: Updated pkg/operator/utils/gcp/utils_test.go to handle gomock API change where InOrder() now expects variadic any parameters
  • Vendor: Updated vendor directory with new mock library

Test Status

✅ All mockgen-related tests pass successfully
❌ Some tests fail due to unrelated blocker: openshift/library-go#2171 (HasSyncedChecker method requirement)

This PR has the same library-go dependency blocker as PR #1066 (CCO-834). Both PRs are waiting for openshift/library-go#2171 to merge before tests can fully pass.

Test Plan

Ran make test - all tests that can run pass. Failures are exclusively from the library-go blocker, not from the mock library migration.

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.

@openshift-ci openshift-ci Bot requested a review from dlom July 14, 2026 18:13
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉


Walkthrough

The module dependency graph was upgraded, the legacy GoMock dependency was replaced with go.uber.org/mock, generated clients were updated, and affected tests switched imports. One call-order assertion was adapted for the new GoMock API.

Changes

GoMock and dependency migration

Layer / File(s) Summary
Module dependency updates
go.mod
Kubernetes, controller-runtime, OpenShift, observability, networking, and GoMock module requirements were updated.
Generated mock package migration
pkg/aws/mock/client_generated.go, pkg/azure/mock/client_generated.go, pkg/gcp/mock/client_generated.go, pkg/ibmcloud/mock/client_generated.go
Generated clients now reference go.uber.org/mock/gomock.
Test mock migration and call ordering
pkg/*/*_test.go, pkg/operator/utils/gcp/utils_test.go
GoMock imports were migrated across tests, and the call-order assertion now passes a []any slice to gomock.InOrder.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: openshift-merge-bot[bot]

🚥 Pre-merge checks | ✅ 14 | ❌ 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 (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: replacing deprecated golang/mock with go.uber.org/mock.
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 No new unstable test titles were introduced; the PR only changes gomock imports and an InOrder compatibility fix, while existing subtest names remain unchanged.
Test Structure And Quality ✅ Passed Touched tests are import-only except one helper API shim; no Ginkgo specs, waits, or cleanup/setup patterns were changed.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the diff only migrates gomock imports/vendor and tweaks a unit test helper.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the diff only updates unit tests, mocks, and vendor deps. The lone topology reference is fixture data, not an HA assumption.
Topology-Aware Scheduling Compatibility ✅ Passed Only dependency, vendor, and test/mock files changed; no deployment manifests or controller scheduling code was modified, so no topology-aware scheduling risk was introduced.
Ote Binary Stdout Contract ✅ Passed Reviewed the PR-named files: the only process-level hooks are init()s that just set log level, and no fmt/klog/stdout writes or TestMain/BeforeSuite hooks were found.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the changed files are unit tests/mocks, and public hostnames only appear in expected-string assertions, not network calls.
No-Weak-Crypto ✅ Passed Diff only migrates gomock imports/vendor and a variadic InOrder adapter; no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret comparisons were added.
Container-Privileges ✅ Passed PR changes only Go code, go.mod, and vendor Go sources; no container/K8s manifests were modified, so no privilege flags are introduced.
No-Sensitive-Data-In-Logs ✅ Passed Patch only changes gomock imports/deps and one InOrder compatibility call; no added logs or sensitive literals found.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@openshift-ci openshift-ci Bot requested a review from jstuever July 14, 2026 18:13
@dlom

dlom commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

/approve

@openshift-ci

openshift-ci Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dlom, ericahinkleRH

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

The pull request process is described 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-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 14, 2026
@ericahinkleRH

ericahinkleRH commented Jul 14, 2026

Copy link
Copy Markdown
Author

Blocker Status

This PR is blocked by the same upstream dependency as PR #1066 (CCO-834):

Waiting on: openshift/library-go#2171 to merge
Top-level blocker: openshift/api#2813

The golang/mockgo.uber.org/mock migration is complete and all mock-related tests pass. However, some tests still fail due to the HasSyncedChecker() method requirement from Kubernetes 1.36, which requires the library-go update.

Once library-go#2171 merges, this PR should be ready to merge.

@openshift-ci

openshift-ci Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

@ericahinkleRH: 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/images b22c306 link true /test images
ci/prow/e2e-aws-ovn b22c306 link true /test e2e-aws-ovn
ci/prow/okd-scos-images b22c306 link true /test okd-scos-images
ci/prow/e2e-azure-manual-oidc b22c306 link true /test e2e-azure-manual-oidc
ci/prow/e2e-upgrade b22c306 link true /test e2e-upgrade
ci/prow/e2e-gcp-manual-oidc b22c306 link true /test e2e-gcp-manual-oidc
ci/prow/e2e-aws-cco-parallel b22c306 link false /test e2e-aws-cco-parallel
ci/prow/coverage b22c306 link true /test coverage
ci/prow/security b22c306 link true /test security
ci/prow/verify b22c306 link true /test verify
ci/prow/e2e-hypershift b22c306 link true /test e2e-hypershift
ci/prow/unit b22c306 link true /test unit

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

approved Indicates a PR has been approved by an approver from all required OWNERS files. 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.

3 participants