Skip to content

NO-ISSUE: Update fake clientsets to NewClientset#1340

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
JoelSpeed:update-golangci-lint
Mar 11, 2026
Merged

NO-ISSUE: Update fake clientsets to NewClientset#1340
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
JoelSpeed:update-golangci-lint

Conversation

@JoelSpeed
Copy link
Contributor

@JoelSpeed JoelSpeed commented Mar 9, 2026

Running the latest golangci-lint against CVO produces only a handful of errors about a deprecated NewSimpleClientset function, this fixes this so that we can update golangci-lint to latest (v2.11.2)

CC @DavidHurta

Summary by CodeRabbit

  • Tests
    • Updated test suites to use the newer fake client initialization across multiple packages.
    • Normalized resource metadata in test comparisons (clearing managed fields) to reduce flaky assertions and make API-call diffing more robust.

@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

Walkthrough

Replaces fake client constructors in three tests and updates security test assertions to normalize and clear ManagedFields before comparing API actions and SecurityContextConstraints; adds a helper to strip ManagedFields from recorded Update actions.

Changes

Cohort / File(s) Summary
Security test updates
lib/resourceapply/security_test.go
Replaced NewSimpleClientset() with NewClientset(). Added clearManagedFields(actions []kubetesting.Action) []kubetesting.Action helper and invoke it when diffing API calls; clear ManagedFields on actual SCC before final comparison to avoid client-runtime metadata in assertions.
Fake client constructor swaps
pkg/cvo/cvo_test.go, pkg/featuregates/featurechangestopper_test.go
Replaced NewSimpleClientset() with NewClientset() in test setups for fake Kubernetes/OpenShift config clients; no logic or assertion changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Stable And Deterministic Test Names ✅ Passed Modified test files use standard Go testing.T framework with static, descriptive subtest names containing no dynamic information. PR changes only affect fake client instantiation, not test naming.
Test Structure And Quality ✅ Passed Tests demonstrate strong structure with single-responsibility test cases, proper setup/cleanup, timeouts, meaningful assertion messages, and consistency with codebase patterns.
Title check ✅ Passed The title accurately reflects the main change: replacing deprecated NewSimpleClientset calls with NewClientset across multiple test files.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/cvo/cvo_test.go (1)

506-515: ⚠️ Potential issue | 🟠 Major

Complete the fake clientset migration in this file.

The PR updates some test cases in pkg/cvo/cvo_test.go to use the new fake clientset constructors, but the file still contains 32 deprecated constructor calls that need to be replaced. This incomplete migration will prevent the lint failure from being resolved. Replace all remaining instances of fake.NewSimpleClientset(...) and kfake.NewSimpleClientset(...) throughout the file with the corresponding new constructors.

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

In `@pkg/cvo/cvo_test.go` around lines 506 - 515, Search pkg/cvo/cvo_test.go for
all uses of fake.NewSimpleClientset(...) and kfake.NewSimpleClientset(...) and
replace them with the new constructors used elsewhere in the file (e.g.,
fake.NewClientset(...) and kfake.NewClientset(...)) so every test uses the
updated fake clientset API; update each test case that currently calls
fake.NewSimpleClientset or kfake.NewSimpleClientset to call the corresponding
NewClientset variant and keep the same object arguments.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@pkg/cvo/cvo_test.go`:
- Around line 506-515: Search pkg/cvo/cvo_test.go for all uses of
fake.NewSimpleClientset(...) and kfake.NewSimpleClientset(...) and replace them
with the new constructors used elsewhere in the file (e.g.,
fake.NewClientset(...) and kfake.NewClientset(...)) so every test uses the
updated fake clientset API; update each test case that currently calls
fake.NewSimpleClientset or kfake.NewSimpleClientset to call the corresponding
NewClientset variant and keep the same object arguments.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 729a9d84-ba95-410c-b822-9bebdf36370f

📥 Commits

Reviewing files that changed from the base of the PR and between c4fb92f and b3c8484.

📒 Files selected for processing (3)
  • lib/resourceapply/security_test.go
  • pkg/cvo/cvo_test.go
  • pkg/featuregates/featurechangestopper_test.go

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
newClient := securityfake.NewSimpleClientset()
newClient := securityfake.NewClientset()
Copy link
Member

Choose a reason for hiding this comment

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

Trying to understand this change, the Godocs say:

Deprecated: NewClientset replaces this with support for field management, which significantly improves server side apply testing. NewClientset is only available when apply configurations are generated (e.g. via --with-applyconfig).

so... we don't need to worry about that "...only available...", because we're not generating the client library? And... we don't care about field-management support, but aren't hurt by it either? Am I understanding the pivot correctly?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like we do need to update some fixtures, or clear managedFields before comparing with fixtures, or some such:

github.com/openshift/cluster-version-operator/lib/resourceapply: TestApplySecurityContextConstraintsv1/create_nonexistent,_expect_modified expand_less	0s
{Failed  === RUN   TestApplySecurityContextConstraintsv1/create_nonexistent,_expect_modified
    security_test.go:187: SCC differs from expected:
          &v1.SecurityContextConstraints{
          	TypeMeta: {Kind: "SecurityContextConstraints", APIVersion: "security.openshift.io/v1"},
          	ObjectMeta: v1.ObjectMeta{
          		... // 12 identical fields
          		OwnerReferences: nil,
          		Finalizers:      nil,
        - 		ManagedFields:   nil,
        + 		ManagedFields: []v1.ManagedFieldsEntry{
        + 			{
        + 				Manager:    "unknown",
        + 				Operation:  "Update",
        + 				APIVersion: "security.openshift.io/v1",
        + 				Time:       s"2026-03-09 17:57:27.879975246 +0000 UTC",
        + 				FieldsType: "FieldsV1",
        + 				FieldsV1:   s`{"f:allowedCapabilities":{},"f:fsGroup":{"f:type":{}},"f:metadat`...,
        + 			},
        + 		},
          	},
          	Priority:                 nil,
          	AllowPrivilegedContainer: false,
          	... // 23 identical fields
          }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed a change to clear the managed fields before comparing. IMO it's not the job of this test suite to be comparing what happens in the managed fields

@JoelSpeed JoelSpeed force-pushed the update-golangci-lint branch from b3c8484 to d5f7201 Compare March 10, 2026 10:26
Copy link

@coderabbitai coderabbitai bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@pkg/cvo/cvo_test.go`:
- Line 506: Multiple test files still call the deprecated NewSimpleClientset;
replace every occurrence of NewSimpleClientset(...) with fake.NewClientset(...)
(preserving the same arguments) across the tests (e.g., the remaining uses in
cvo_test and upgradeable_test) so all fake client construction uses the new
NewClientset symbol; ensure imports remain correct and run tests/linter to
verify no deprecated usages remain.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 97aa1a2f-3bc6-4a23-9582-1c602dd03893

📥 Commits

Reviewing files that changed from the base of the PR and between b3c8484 and d5f7201.

📒 Files selected for processing (3)
  • lib/resourceapply/security_test.go
  • pkg/cvo/cvo_test.go
  • pkg/featuregates/featurechangestopper_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/featuregates/featurechangestopper_test.go

namespace: "test",
name: "default",
client: fake.NewSimpleClientset(
client: fake.NewClientset(
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find all remaining usages of NewSimpleClientset in the codebase
rg -n "NewSimpleClientset" --type go

Repository: openshift/cluster-version-operator

Length of output: 3464


Incomplete migration: Dozens of NewSimpleClientset instances remain.

This change correctly updates fake.NewSimpleClientset to fake.NewClientset at lines 506, 563, and 4233, but the migration is far more incomplete than initially apparent. A comprehensive search reveals 33 additional instances of the deprecated NewSimpleClientset function still in use across the test files:

  • pkg/cvo/cvo_test.go: 32 instances at lines 436, 2039, 2324, 2340, 2384, 2427, 2471, 2535, 2603, 2664, 2705, 2842, 2857, 2900, 2953, 3014, 3078, 3144, 3223, 3257, 3293, 3341, 3385, 3429, 3473, 3517, 3562, 3603, 3653, 3698, 3747, 3786
  • pkg/cvo/upgradeable_test.go:143: 1 instance

These remaining usages will continue to trigger golangci-lint deprecation warnings and should all be updated to NewClientset() for consistency.

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

In `@pkg/cvo/cvo_test.go` at line 506, Multiple test files still call the
deprecated NewSimpleClientset; replace every occurrence of
NewSimpleClientset(...) with fake.NewClientset(...) (preserving the same
arguments) across the tests (e.g., the remaining uses in cvo_test and
upgradeable_test) so all fake client construction uses the new NewClientset
symbol; ensure imports remain correct and run tests/linter to verify no
deprecated usages remain.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 10, 2026

@JoelSpeed: The following test 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-agnostic-ovn-techpreview-serial b3c8484 link true /test e2e-agnostic-ovn-techpreview-serial

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.

Copy link
Member

@wking wking left a comment

Choose a reason for hiding this comment

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

/lgtm

The CI issues are unrelated to this pull:

/override ci/prow/e2e-agnostic-ovn
/override ci/prow/e2e-agnostic-ovn-techpreview-serial-1of3

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 10, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 10, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JoelSpeed, wking

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
Copy link
Contributor

openshift-ci bot commented Mar 10, 2026

@wking: Overrode contexts on behalf of wking: ci/prow/e2e-agnostic-ovn, ci/prow/e2e-agnostic-ovn-techpreview-serial-1of3

Details

In response to this:

/lgtm

The CI issues are unrelated to this pull:

/override ci/prow/e2e-agnostic-ovn
/override ci/prow/e2e-agnostic-ovn-techpreview-serial-1of3

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.

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 10, 2026
@wking wking changed the title Update fake clientsets to NewClientset NO-ISSUE: Update fake clientsets to NewClientset Mar 11, 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 Mar 11, 2026
@openshift-ci-robot
Copy link
Contributor

@JoelSpeed: This pull request explicitly references no jira issue.

Details

In response to this:

Running the latest golangci-lint against CVO produces only a handful of errors about a deprecated NewSimpleClientset function, this fixes this so that we can update golangci-lint to latest (v2.11.2)

CC @DavidHurta

Summary by CodeRabbit

  • Tests
  • Updated test suites to use the newer fake client initialization across multiple packages.
  • Normalized resource metadata in test comparisons (clearing managed fields) to reduce flaky assertions and make API-call diffing more robust.

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.

@wking
Copy link
Member

wking commented Mar 11, 2026

/verified by the e2e CI we're adjusting still passing

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Mar 11, 2026
@openshift-ci-robot
Copy link
Contributor

@wking: This PR has been marked as verified by the e2e CI we're adjusting still passing.

Details

In response to this:

/verified by the e2e CI we're adjusting still passing

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.

@wking
Copy link
Member

wking commented Mar 11, 2026

Don't wait for the expensive retries; none of the changes that have merged into the main branch since the previous tests will have broken this fix.

/override ci/prow/e2e-agnostic-operator
/override ci/prow/e2e-agnostic-ovn
/override ci/prow/e2e-agnostic-ovn-techpreview-serial-1of3
/override ci/prow/e2e-agnostic-ovn-techpreview-serial-2of3
/override ci/prow/e2e-agnostic-ovn-techpreview-serial-3of3
/override ci/prow/e2e-agnostic-ovn-upgrade-into-change
/override ci/prow/e2e-agnostic-ovn-upgrade-out-of-change
/override ci/prow/e2e-aws-ovn-techpreview
/override ci/prow/e2e-hypershift
/override ci/prow/e2e-hypershift-conformance

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 11, 2026

@wking: Overrode contexts on behalf of wking: ci/prow/e2e-agnostic-operator, ci/prow/e2e-agnostic-ovn, ci/prow/e2e-agnostic-ovn-techpreview-serial-1of3, ci/prow/e2e-agnostic-ovn-techpreview-serial-2of3, ci/prow/e2e-agnostic-ovn-techpreview-serial-3of3, ci/prow/e2e-agnostic-ovn-upgrade-into-change, ci/prow/e2e-agnostic-ovn-upgrade-out-of-change, ci/prow/e2e-aws-ovn-techpreview, ci/prow/e2e-hypershift, ci/prow/e2e-hypershift-conformance

Details

In response to this:

Don't wait for the expensive retries; none of the changes that have merged into the main branch since the previous tests will have broken this fix.

/override ci/prow/e2e-agnostic-operator
/override ci/prow/e2e-agnostic-ovn
/override ci/prow/e2e-agnostic-ovn-techpreview-serial-1of3
/override ci/prow/e2e-agnostic-ovn-techpreview-serial-2of3
/override ci/prow/e2e-agnostic-ovn-techpreview-serial-3of3
/override ci/prow/e2e-agnostic-ovn-upgrade-into-change
/override ci/prow/e2e-agnostic-ovn-upgrade-out-of-change
/override ci/prow/e2e-aws-ovn-techpreview
/override ci/prow/e2e-hypershift
/override ci/prow/e2e-hypershift-conformance

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.

@openshift-merge-bot openshift-merge-bot bot merged commit ffe4646 into openshift:main Mar 11, 2026
19 checks passed
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. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants