Skip to content

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

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

CCO-837: Replace deprecated golang/mock with go.uber.org/mock#1067
ericahinkleRH wants to merge 3 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 the Go toolchain directive and refreshed core Kubernetes/OpenShift and related platform dependencies.
    • Migrated GoMock usage from the legacy module to go.uber.org/mock (including generated mocks).
  • Documentation
    • Added a new guide for upgrading to Kubernetes 1.36, including CI/e2e validation guidance.
  • Tests
    • Added new end-to-end tests for Kubernetes 1.36 compatibility (cache sync/handshake behavior and controller-manager startup).
    • Updated existing tests to use the new GoMock import and adjusted one mock ordering expectation.

@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

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

The dependency graph was upgraded for Kubernetes 1.36, GoMock was migrated to go.uber.org/mock, generated clients and tests were updated, and new e2e checks and upgrade documentation were added.

Changes

Kubernetes 1.36 upgrade

Layer / File(s) Summary
Dependency and GoMock module updates
go.mod
The Go toolchain, Kubernetes, OpenShift, controller-runtime, GoMock, observability, networking, and other module requirements were updated.
Generated mocks and test migration
pkg/*/mock/client_generated.go, pkg/**/*_test.go
Generated clients and mock-based tests now use go.uber.org/mock/gomock; one gomock.InOrder call adapts its arguments through []any.
Kubernetes 1.36 end-to-end checks
test/e2e/k8s136/k8s_1_36_upgrade_test.go
New e2e tests check CCO deployment readiness, running pod logs, and deployment availability.
Upgrade documentation
docs/K8S_1.36_UPGRADE.md
Documents the controller-runtime cache API change, CI coverage, e2e scope, verification checklist, dependency context, and rollback procedure.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant E2ETest
  participant KubernetesAPI
  participant CCOPod
  E2ETest->>KubernetesAPI: Fetch CCO deployment and pods
  KubernetesAPI-->>E2ETest: Return readiness and pod status
  E2ETest->>CCOPod: Read running pod logs
  CCOPod-->>E2ETest: Return controller and cache messages
  E2ETest->>KubernetesAPI: Check deployment availability
  KubernetesAPI-->>E2ETest: Return Available condition
Loading

Suggested reviewers: dlom, jstuever

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.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: migrating from deprecated golang/mock to 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 dynamic values in test titles; the new e2e feature/assess names are static and deterministic.
Test Structure And Quality ✅ Passed The new e2e tests use per-assessment timeouts, create no resources, and include clear failure messages; they follow existing e2e-framework patterns.
Microshift Test Compatibility ✅ Passed The new e2e test only uses core/v1 Pods and AppsV1 Deployments; it doesn't touch any MicroShift-banned OpenShift APIs, namespaces, or multi-node assumptions.
Single Node Openshift (Sno) Test Compatibility ✅ Passed New e2e tests only verify CCO deployment health, pod logs, and availability; no multi-node/HA assumptions or SNO skip logic were found.
Topology-Aware Scheduling Compatibility ✅ Passed No new scheduling constraints were introduced; the PR only updates deps, tests, docs, and vendor, and the only topology logic touched is an existing topology-aware test.
Ote Binary Stdout Contract ✅ Passed The new TestMain and all touched init/process-level blocks only set up env/metrics/schemes; no stdout writes or log-to-stdout calls were found. Vendor gomock only writes to buffers.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The new e2e tests only use the cluster API and pod logs; no hardcoded IPv4, IPv4-only parsing, or external/public network calls were found.
No-Weak-Crypto ✅ Passed PASS: The diff only updates gomock imports/docs/tests and dependency versions; no MD5/SHA1/DES/RC4/3DES/ECB, custom crypto, or secret comparisons appear in touched files.
Container-Privileges ✅ Passed No changed files introduce privileged K8s/container settings; repo search found only allowPrivilegeEscalation:false and no hostPID/hostNetwork/hostIPC/SYS_ADMIN/root settings.
No-Sensitive-Data-In-Logs ✅ Passed No changed file logs secrets or customer data; new e2e/test logs only pod names, readiness, and generic error strings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ericahinkleRH

Copy link
Copy Markdown
Author

Updated toolchain to Go 1.26.5 to fix security scan! ✅

Applied same fix from CCO-834/835/836 PR:

- toolchain go1.26.4
+ toolchain go1.26.5

This should resolve the security scan CVEs (SNYK-GOLANG-STDOS-17905377, SNYK-GOLANG-STDCRYPTOTLS-17905406).

/test security
/retest-required

@ericahinkleRH

ericahinkleRH commented Jul 17, 2026

Copy link
Copy Markdown
Author

Rebased on latest master and applied all CCO-834 fixes! ✅

Changes:

  • 🔧 Updated toolchain to Go 1.26.5 (fixes security CVEs)
  • 📦 Updated library-go to v0.0.0-20260716104731-fdf18b82797f (HasSyncedChecker support)
  • 🎨 Applied gofmt to test files after mock migration
  • 🔄 Rebased on master to remove stale CCO-834 commits

This should now pass all tests! The verify test was failing because vendor/ had outdated library-go.

/retest-required

@ericahinkleRH
ericahinkleRH force-pushed the CCO-837 branch 2 times, most recently from 942ee30 to a110ff6 Compare July 17, 2026 12:53
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.30%. Comparing base (672b790) to head (cddbf6c).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1067   +/-   ##
=======================================
  Coverage   47.30%   47.30%           
=======================================
  Files          97       97           
  Lines       12614    12614           
=======================================
  Hits         5967     5967           
  Misses       5987     5987           
  Partials      660      660           
Files with missing lines Coverage Δ
pkg/aws/mock/client_generated.go 49.74% <ø> (ø)
pkg/azure/mock/client_generated.go 70.08% <ø> (ø)
pkg/gcp/mock/client_generated.go 84.29% <ø> (ø)
pkg/ibmcloud/mock/client_generated.go 82.35% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-gcp-manual-oidc

@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-hypershift

@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-aws-ovn

@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-azure-manual-oidc

@ericahinkleRH

Copy link
Copy Markdown
Author

/retest

… tests

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. Update to official library-go with HasSyncedChecker support. Update toolchain to Go 1.26.5 to fix security scan.

Add e2e tests for K8s 1.36 HasSyncedChecker functionality and controller manager startup verification.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-hypershift

@ericahinkleRH
ericahinkleRH force-pushed the CCO-837 branch 2 times, most recently from 64c953c to 52f1dd1 Compare July 22, 2026 17:54
@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-hypershift

1 similar comment
@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-hypershift

The golang/mock repository is no longer maintained and recommends migrating to go.uber.org/mock as a maintained fork.

Changes:
- Updated go.mod dependency from golang/mock v1.7.0-rc.1 to go.uber.org/mock v0.6.0
- Replaced import paths in test files and generated mocks
- Vendored new dependency

Depends on CCO-834 (K8s 1.36 upgrade) for Go version compatibility.

Jira: https://redhat.atlassian.net/browse/CCO-837

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixes Snyk HIGH severity vulnerabilities:
- SNYK-GOLANG-GOOGLEGOLANGORGGRPCINTERNALXDSRBAC-18172577 (Incorrect Authorization)
- SNYK-GOLANG-GOOGLEGOLANGORGGRPCINTERNALTRANSPORT-18172578 (Incorrect Authorization)

Both fixed in grpc v1.82.1.
@ericahinkleRH

Copy link
Copy Markdown
Author

/test e2e-azure-manual-oidc
/test e2e-gcp-manual-oidc

@openshift-ci

openshift-ci Bot commented Jul 23, 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/e2e-azure-manual-oidc cddbf6c link true /test e2e-azure-manual-oidc
ci/prow/e2e-gcp-manual-oidc cddbf6c link true /test e2e-gcp-manual-oidc

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.

@ericahinkleRH

Copy link
Copy Markdown
Author

Hey! The two manual-oidc tests keep failing consistently across multiple retests (tried July 17 and July 23, same failures
both times):

  • e2e-gcp-manual-oidc fails on TestProjectWatch (auth test that panics)
  • e2e-azure-manual-oidc fails on a load balancer availability monitor (times out after 49 minutes)

Both are OpenShift platform tests (sig-auth and sig-network-edge), not CCO-specific tests. This PR only swaps the import paths from github.com/golang/mock to go.uber.org/mock, so I'm not sure how it could affect platform auth or networking.

Interestingly, PR #1004 from March modified the same pkg/gcp/mock/client_generated.go file and the GCP manual-oidc test passed fine then.

Have you seen these tests fail recently on other PRs, or should I keep retesting? Not sure if this is something that needs
investigating or if they can be overridden.

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