Skip to content

NO-JIRA: add more rotation tests scenarios - #2149

Closed
tjungblu wants to merge 1 commit into
openshift:mainfrom
tjungblu:rotation_tests
Closed

NO-JIRA: add more rotation tests scenarios#2149
tjungblu wants to merge 1 commit into
openshift:mainfrom
tjungblu:rotation_tests

Conversation

@tjungblu

@tjungblu tjungblu commented May 12, 2026

Copy link
Copy Markdown
Contributor

from library-go openshift/library-go#2218

/hold

Summary by CodeRabbit

  • Tests

    • Added two end-to-end encryption rotation scenarios (during initial storage migration and during ongoing rotation).
    • Reused common test wiring and introduced shared helpers to update unsupported-config overrides and to retrieve operator conditions.
  • Chores

    • Changed module resolution via a dependency replacement in project configuration.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 12, 2026
@openshift-ci-robot

Copy link
Copy Markdown

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

Details

In response to this:

from library-go openshift/library-go#2218

/hold

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 added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 12, 2026
@coderabbitai

coderabbitai Bot commented May 12, 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

Adds two cluster-operator test helpers, redirects library-go to a fork via go.mod replace, and refactors/extends e2e encryption-rotation tests to use the new helpers and add operator condition checks during migration and rotation scenarios.

Changes

Encryption rotation tests and operator helpers

Layer / File(s) Summary
Dependency redirect (go.mod)
go.mod
Added replace github.com/openshift/library-go => github.com/tjungblu/library-go v0.0.0-20260520063220-fea2dbe4012f.
Cluster operator helper APIs
test/library/encryption/helpers.go
Added UpdateUnsupportedConfig(t *testing.T, raw []byte) error (sets Spec.UnsupportedConfigOverrides.Raw on the cluster KubeAPIServer operator and updates it) and GetClusterOperatorConditions(t testing.TB) ([]operatorv1.OperatorCondition, error) (returns Status.Conditions).
Test wiring: use helpers for unsupported-config updates
test/e2e-encryption-rotation/encryption_rotation_test.go
TestEncryptionRotation now delegates unsupported-config updates to operatorencryption.UpdateUnsupportedConfig and removed unused context/metav1 imports.
New test cases validating operator conditions during rotation/migration
test/e2e-encryption-rotation/encryption_rotation_test.go
Added TestEncryptionRotationDuringFirstMigration and TestEncryptionRotationDuringOngoingRotation, both using GetOperatorConditionsFunc: operatorencryption.GetClusterOperatorConditions and delegating unsupported-config updates to operatorencryption.UpdateUnsupportedConfig.

Sequence Diagram(s)

sequenceDiagram
  participant TestRunner
  participant rotationScenario
  participant operatorencryption
  participant KubeAPIServerOperator
  TestRunner->>rotationScenario: start rotation test
  rotationScenario->>operatorencryption: UnsupportedConfigFunc -> UpdateUnsupportedConfig(raw)
  operatorencryption->>KubeAPIServerOperator: Get Operator / Update Spec.UnsupportedConfigOverrides.Raw
  rotationScenario->>operatorencryption: GetOperatorConditionsFunc -> GetClusterOperatorConditions()
  operatorencryption->>KubeAPIServerOperator: Get Operator -> return Status.Conditions
  rotationScenario->>TestRunner: complete with pass/fail
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • benluddy
🚥 Pre-merge checks | ✅ 9 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Microshift Test Compatibility ⚠️ Warning Two new tests use GetClusterOperatorConditions without MicroShift protection ([Skipped:MicroShift], [apigroup:...], or exutil.IsMicroShiftCluster() checks). Add [Skipped:MicroShift] label to test names, use [apigroup:operator.openshift.io] tags, or add exutil.IsMicroShiftCluster() runtime checks to guard the tests from running on MicroShift.
Ipv6 And Disconnected Network Test Compatibility ⚠️ Warning New tests use GetRawSecretOfLife which relies on library-go's etcd client with hardcoded 127.0.0.1 IPv4 localhost, incompatible with IPv6. Update library-go etcd_client.go to support IPv6, or add runtime IPv6 detection/skip to new test functions.
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding two new test scenarios for encryption rotation (TestEncryptionRotationDuringFirstMigration and TestEncryptionRotationDuringOngoingRotation) and refactoring related test helpers.
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 PR adds standard Go test functions (not Ginkgo tests) with static, deterministic names. The custom check applies only to Ginkgo It/Describe/Context/When tests, which this PR does not use.
Test Structure And Quality ✅ Passed These are standard Go tests, not Ginkgo tests. The custom check requires reviewing Ginkgo test code patterns (BeforeEach/AfterEach, It blocks), which are absent here.
Single Node Openshift (Sno) Test Compatibility ✅ Passed New encryption rotation tests use only cluster-wide APIs (ClusterOperator, Secrets, ConfigMaps) available on SNO and make no multi-node assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed PR only modifies test code and go.mod dependency management; no deployment manifests, operator code, or scheduling constraints are introduced.
Ote Binary Stdout Contract ✅ Passed No OTE Binary Stdout Contract violations detected. The PR adds only test functions and helper functions with no process-level stdout writes, unredirected klog, or fmt.Print calls.

✏️ 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 and usage tips.

@openshift-ci
openshift-ci Bot requested review from flavianmissi and gangwgr May 12, 2026 11:53
@openshift-ci

openshift-ci Bot commented May 12, 2026

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 kaleemsiddiqu 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

@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 140: The go.mod currently contains a replace directive pointing
github.com/openshift/library-go to a personal fork
(github.com/tjungblu/library-go) — remove that replace directive and restore
usage of the official module (github.com/openshift/library-go) by either
reverting the replace line or replacing it with the appropriate upstream
version/tag once PR `#2218` is merged (or choose a stable upstream version if the
PR won’t be accepted); after updating go.mod, run dependency cleanup (e.g., go
mod tidy) to refresh go.sum and ensure the module graph is consistent.
🪄 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: 620b9dd7-48ee-4982-865e-a199272eedf3

📥 Commits

Reviewing files that changed from the base of the PR and between ee66dc7 and 4c219eb.

⛔ Files ignored due to path filters (8)
  • go.sum is excluded by !**/*.sum
  • vendor/github.com/openshift/library-go/pkg/operator/encryption/controllers/migration_controller.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/library-go/pkg/operator/encryption/controllers/state_controller.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/library-go/pkg/operator/encryption/encryptiondata/config.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/library-go/test/library/encryption/helpers.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/library-go/test/library/encryption/perf_scenarios.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/library-go/test/library/encryption/scenarios.go is excluded by !**/vendor/**, !vendor/**
  • vendor/modules.txt is excluded by !**/vendor/**, !vendor/**
📒 Files selected for processing (3)
  • go.mod
  • test/e2e-encryption-rotation/encryption_rotation_test.go
  • test/library/encryption/helpers.go

Comment thread go.mod Outdated

replace github.com/onsi/ginkgo/v2 => github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20251001123353-fd5b1fb35db1

replace github.com/openshift/library-go => github.com/tjungblu/library-go v0.0.0-20260512113548-2e4a77cb3139

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 | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Has https://github.com/openshift/library-go/pull/2218 merged, and what upstream commit/tag contains those changes so this replace can be removed?

💡 Result:

No evidence found that openshift/library-go#2218 has merged or exists. Searches across GitHub, OpenShift repos, and web did not return the specific PR page, merge commit, or references to it being merged [1][2][3]. The library-go repo was last pushed on 2026-03-26 [1], but no mention of PR 2218 in recent bumps like #2076 [3] or others [4][5][6]. Without the PR merged into master, there is no upstream commit or tag containing those changes, so any replace directive cannot be removed yet. Check the PR status directly on GitHub or if the number is correct.

Citations:


Remove the personal-fork module replace before merging.

Line 140 pins github.com/openshift/library-go to a personal fork (github.com/tjungblu/library-go), which weakens dependency provenance and can hurt reproducibility if that fork or commit moves or is removed. The referenced upstream PR (#2218) does not appear to have been merged yet. Switch back to an official github.com/openshift/library-go version once the upstream PR is merged, or identify an alternative stable upstream version to use instead.

🤖 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 140, The go.mod currently contains a replace directive
pointing github.com/openshift/library-go to a personal fork
(github.com/tjungblu/library-go) — remove that replace directive and restore
usage of the official module (github.com/openshift/library-go) by either
reverting the replace line or replacing it with the appropriate upstream
version/tag once PR `#2218` is merged (or choose a stable upstream version if the
PR won’t be accepted); after updating go.mod, run dependency cleanup (e.g., go
mod tidy) to refresh go.sum and ensure the module graph is consistent.

@tjungblu
tjungblu force-pushed the rotation_tests branch 2 times, most recently from 070c3a4 to 0d620d6 Compare May 15, 2026 10:06
@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 15, 2026
@openshift-ci openshift-ci Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 15, 2026

@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 `@test/e2e-encryption-rotation/encryption_rotation_test.go`:
- Line 35: The test is passing the wrong type to the EncryptionProvider field —
replace uses of configv1.EncryptionType(*provider) with
configv1.APIServerEncryption(*provider) so the field receives the expected type;
update both occurrences where EncryptionProvider is set (the earlier two
instances that mirror the correct pattern used later) to use
configv1.APIServerEncryption to match the working example in the file.
🪄 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: 28136918-5eb8-4290-9043-b947ce3bcc5a

📥 Commits

Reviewing files that changed from the base of the PR and between 070c3a4 and 0309bec.

⛔ Files ignored due to path filters (6)
  • go.sum is excluded by !**/*.sum
  • vendor/github.com/openshift/library-go/test/library/encryption/helpers.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/library-go/test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/library-go/test/library/encryption/perf_scenarios.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/library-go/test/library/encryption/scenarios.go is excluded by !**/vendor/**, !vendor/**
  • vendor/modules.txt is excluded by !**/vendor/**, !vendor/**
📒 Files selected for processing (3)
  • go.mod
  • test/e2e-encryption-rotation/encryption_rotation_test.go
  • test/library/encryption/helpers.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • go.mod
  • test/library/encryption/helpers.go

Comment thread test/e2e-encryption-rotation/encryption_rotation_test.go Outdated
@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 17, 2026
@openshift-ci

openshift-ci Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor

PR needs rebase.

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.

from library-go openshift/library-go#2218

Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>
@openshift-ci

openshift-ci Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

@tjungblu: 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-gcp-operator-encryption-kms-2of2 ca13b38 link false /test e2e-gcp-operator-encryption-kms-2of2
ci/prow/e2e-gcp-operator-encryption-single-node af89f72 link false /test e2e-gcp-operator-encryption-single-node
ci/prow/e2e-gcp-operator-encryption-rotation-aesgcm af89f72 link false /test e2e-gcp-operator-encryption-rotation-aesgcm
ci/prow/verify-deps af89f72 link true /test verify-deps
ci/prow/k8s-e2e-gcp af89f72 link true /test k8s-e2e-gcp
ci/prow/e2e-aws-ovn-serial-1of2 af89f72 link true /test e2e-aws-ovn-serial-1of2
ci/prow/e2e-gcp-operator-encryption-perf-single-node af89f72 link false /test e2e-gcp-operator-encryption-perf-single-node
ci/prow/verify af89f72 link true /test verify
ci/prow/e2e-gcp-operator-encryption-aescbc af89f72 link false /test e2e-gcp-operator-encryption-aescbc
ci/prow/unit af89f72 link true /test unit
ci/prow/e2e-gcp-operator-encryption-kms af89f72 link false /test e2e-gcp-operator-encryption-kms
ci/prow/e2e-gcp-operator-encryption-kms-rotation af89f72 link false /test e2e-gcp-operator-encryption-kms-rotation
ci/prow/e2e-aws-ovn-serial-2of2 af89f72 link true /test e2e-aws-ovn-serial-2of2
ci/prow/images af89f72 link true /test images
ci/prow/e2e-gcp-operator-encryption-perf-aescbc af89f72 link false /test e2e-gcp-operator-encryption-perf-aescbc
ci/prow/e2e-aws-ovn-upgrade af89f72 link true /test e2e-aws-ovn-upgrade
ci/prow/e2e-aws-ovn af89f72 link true /test e2e-aws-ovn
ci/prow/e2e-gcp-operator-encryption-perf-aesgcm af89f72 link false /test e2e-gcp-operator-encryption-perf-aesgcm
ci/prow/okd-scos-images af89f72 link true /test okd-scos-images
ci/prow/e2e-gcp-operator af89f72 link true /test e2e-gcp-operator
ci/prow/periodics-images af89f72 link true /test periodics-images
ci/prow/e2e-gcp-operator-encryption-rotation-single-node af89f72 link false /test e2e-gcp-operator-encryption-rotation-single-node
ci/prow/e2e-gcp-operator-encryption-aesgcm af89f72 link false /test e2e-gcp-operator-encryption-aesgcm
ci/prow/e2e-gcp-operator-encryption-rotation-aescbc af89f72 link false /test e2e-gcp-operator-encryption-rotation-aescbc
ci/prow/e2e-gcp-operator-serial-ote af89f72 link true /test e2e-gcp-operator-serial-ote

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.

@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: 2

♻️ Duplicate comments (1)
go.mod (1)

140-140: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove the personal-fork library-go replace before merge.

Line 140 redirects to github.com/tjungblu/library-go, which reduces supply-chain provenance and release reproducibility for this repo. Please switch back to the official github.com/openshift/library-go source once the upstream change is available.

Has https://github.com/openshift/library-go/pull/2218 merged, and what official github.com/openshift/library-go commit/tag should be used in go.mod instead of a fork replace?
🤖 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 140, The go.mod currently contains a replace directive
pointing to a personal fork (replace github.com/openshift/library-go =>
github.com/tjungblu/library-go ...); remove that forked replace before merge and
restore the official module path (github.com/openshift/library-go) by either
deleting the replace line or updating it to the official upstream commit/tag
once the upstream PR (e.g. openshift/library-go#2218) has merged; locate the
replace entry in go.mod and replace or remove it so the module resolution uses
the canonical github.com/openshift/library-go source and update the go.sum via
`go mod tidy` afterwards.
🤖 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 `@test/e2e-encryption-rotation/encryption_rotation_test.go`:
- Around line 41-60: This test (TestEncryptionRotationDuringFirstMigration)
calls GetClusterOperatorConditions via
library.TestEncryptionRotationDuringFirstMigration and must be guarded from
running on MicroShift; add the standard MicroShift protection by either tagging
the test with the API-specific tag/[Skipped:MicroShift] or performing a runtime
skip at the top of TestEncryptionRotationDuringFirstMigration (e.g., call
exutil.IsMicroShiftCluster() and t.Skipf when true) so ClusterOperator-dependent
logic is not executed on MicroShift, and apply the same change to the other
related test block (the similar test around lines 64-83) that also uses
GetClusterOperatorConditions.

In `@test/library/encryption/helpers.go`:
- Around line 93-94: Wrap the single operatorClient.Update call in a
retry.RetryOnConflict loop using retry.DefaultBackoff from
k8s.io/client-go/util/retry to handle update conflicts; inside the closure call
operatorClient.Update(ctx, apiServerOperator, metav1.UpdateOptions{}), and on
conflict fetch the latest apiServerOperator (via operatorClient.Get) and reapply
your changes before retrying so the update eventually succeeds. Ensure you
import k8s.io/client-go/util/retry and keep using metav1.UpdateOptions{} and the
same context (context.TODO or passed ctx).

---

Duplicate comments:
In `@go.mod`:
- Line 140: The go.mod currently contains a replace directive pointing to a
personal fork (replace github.com/openshift/library-go =>
github.com/tjungblu/library-go ...); remove that forked replace before merge and
restore the official module path (github.com/openshift/library-go) by either
deleting the replace line or updating it to the official upstream commit/tag
once the upstream PR (e.g. openshift/library-go#2218) has merged; locate the
replace entry in go.mod and replace or remove it so the module resolution uses
the canonical github.com/openshift/library-go source and update the go.sum via
`go mod tidy` afterwards.
🪄 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: 38d9f4e2-b382-46f2-b53c-6db3d659100e

📥 Commits

Reviewing files that changed from the base of the PR and between ca13b38 and 4a2f2a6.

⛔ Files ignored due to path filters (7)
  • go.sum is excluded by !**/*.sum
  • vendor/github.com/openshift/library-go/test/library/encryption/helpers.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/library-go/test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/library-go/test/library/encryption/kms/vault.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/library-go/test/library/encryption/perf_scenarios.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/library-go/test/library/encryption/scenarios.go is excluded by !**/vendor/**, !vendor/**
  • vendor/modules.txt is excluded by !**/vendor/**, !vendor/**
📒 Files selected for processing (3)
  • go.mod
  • test/e2e-encryption-rotation/encryption_rotation_test.go
  • test/library/encryption/helpers.go

Comment on lines +41 to +60
func TestEncryptionRotationDuringFirstMigration(t *testing.T) {
library.TestEncryptionRotationDuringFirstMigration(t, library.RotationScenario{
BasicScenario: library.BasicScenario{
Namespace: operatorclient.GlobalMachineSpecifiedConfigNamespace,
LabelSelector: "encryption.apiserver.operator.openshift.io/component" + "=" + operatorclient.TargetNamespace,
EncryptionConfigSecretName: fmt.Sprintf("encryption-config-%s", operatorclient.TargetNamespace),
EncryptionConfigSecretNamespace: operatorclient.GlobalMachineSpecifiedConfigNamespace,
OperatorNamespace: operatorclient.OperatorNamespace,
TargetGRs: operatorencryption.DefaultTargetGRs,
AssertFunc: operatorencryption.AssertSecretsAndConfigMaps,
},
CreateResourceFunc: operatorencryption.CreateAndStoreSecretOfLife,
GetRawResourceFunc: operatorencryption.GetRawSecretOfLife,
GetOperatorConditionsFunc: operatorencryption.GetClusterOperatorConditions,
UnsupportedConfigFunc: func(raw []byte) error {
return operatorencryption.UpdateUnsupportedConfig(t, raw)
},
EncryptionProvider: configv1.APIServerEncryption{Type: configv1.EncryptionType(*provider)},
})
}

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 | ⚡ Quick win

Guard new rotation tests for MicroShift incompatibility.

These new tests depend on ClusterOperator conditions (GetClusterOperatorConditions), which are not available on MicroShift. Add the usual MicroShift protection (label/tag or runtime skip) so they don’t run in unsupported environments.

As per coding guidelines, “Flag tests referencing unavailable APIs: … ClusterOperator … Use [apigroup:...] tags for API-specific tests, add [Skipped:MicroShift] label, or use exutil.IsMicroShiftCluster() runtime checks.”

Also applies to: 64-83

🧰 Tools
🪛 golangci-lint (2.12.2)

[error] 56-56: : # github.com/openshift/cluster-kube-apiserver-operator/test/e2e-encryption [github.com/openshift/cluster-kube-apiserver-operator/test/e2e-encryption.test]
test/e2e-encryption/encryption_test.go:56:35: cannot use configv1.APIServerEncryption{…} (value of struct type "github.com/openshift/api/config/v1".APIServerEncryption) as "github.com/openshift/library-go/test/library/encryption".EncryptionProvider value in struct literal

(typecheck)

🤖 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 `@test/e2e-encryption-rotation/encryption_rotation_test.go` around lines 41 -
60, This test (TestEncryptionRotationDuringFirstMigration) calls
GetClusterOperatorConditions via
library.TestEncryptionRotationDuringFirstMigration and must be guarded from
running on MicroShift; add the standard MicroShift protection by either tagging
the test with the API-specific tag/[Skipped:MicroShift] or performing a runtime
skip at the top of TestEncryptionRotationDuringFirstMigration (e.g., call
exutil.IsMicroShiftCluster() and t.Skipf when true) so ClusterOperator-dependent
logic is not executed on MicroShift, and apply the same change to the other
related test block (the similar test around lines 64-83) that also uses
GetClusterOperatorConditions.

Comment on lines +93 to +94
_, err = operatorClient.Update(context.TODO(), apiServerOperator, metav1.UpdateOptions{})
return err

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 | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
# Verify whether update helpers in this file already use retry-on-conflict.
rg -n -C2 'func UpdateUnsupportedConfig|RetryOnConflict|operatorClient\.Update\(' test/library/encryption/helpers.go

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 481


🏁 Script executed:

# Check the full file content to understand context and imports
head -30 test/library/encryption/helpers.go

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 939


🏁 Script executed:

# Look for all Update calls in the file
rg -n '\.Update\(' test/library/encryption/helpers.go

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 179


🏁 Script executed:

# Check if retry pattern is used elsewhere in the file or related test utilities
rg -n 'RetryOnConflict|retry\.Retry' test/library/encryption/helpers.go

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 67


🏁 Script executed:

# Search for similar update patterns in other test helper files
fd -e go -path "*/test/library/*" | head -10

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 254


🏁 Script executed:

# Check if k8s.io/client-go/util/retry is used anywhere in the codebase
rg -n 'client-go/util/retry|RetryOnConflict' --type go

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 3188


🏁 Script executed:

# Look for similar Update patterns in other test files
rg -n -B2 'operatorClient.*Update' --type go test/

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 813


🏁 Script executed:

# Check if there are any retry patterns in the broader codebase
rg -n 'retry\.Retry|retry\.DefaultRetry' --type go | head -20

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 2696


🏁 Script executed:

# Check what exists in the vendor code - DefaultRetry vs DefaultBackoff
rg -n 'var DefaultRetry|var DefaultBackoff|DefaultRetry =|DefaultBackoff =' vendor/k8s.io/client-go/util/retry/ --type go

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 245


🏁 Script executed:

# Check the library-go encryption helpers that are imported
rg -n -A10 'func UpdateUnsupportedConfig' vendor/github.com/openshift/library-go/test/library/encryption/helpers.go

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 67


🏁 Script executed:

# Check the exact signature of RetryOnConflict in vendor
rg -n -A5 'func RetryOnConflict' vendor/k8s.io/client-go/util/retry/util.go

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 215


🏁 Script executed:

# Check the difference between DefaultRetry and DefaultBackoff
rg -n -A10 'var DefaultRetry = wait.Backoff|var DefaultBackoff = wait.Backoff' vendor/k8s.io/client-go/util/retry/util.go

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 877


🏁 Script executed:

# Check if the library-go helpers are actually being used by this file
rg -n 'library\.|library-go' test/library/encryption/helpers.go

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 429


🏁 Script executed:

# Look more broadly for any UpdateUnsupportedConfig patterns in library-go test helpers
rg -n 'UpdateUnsupportedConfig\|UnsupportedConfigOverrides' vendor/github.com/openshift/library-go/test/library/encryption/

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 67


🏁 Script executed:

# Check what the recommended pattern is in similar test helpers
rg -n 'RetryOnConflict.*DefaultRetry|RetryOnConflict.*DefaultBackoff' --type go | head -15

Repository: openshift/cluster-kube-apiserver-operator

Length of output: 1410


Use retry-on-conflict when updating operator resources.

Line 93 performs a single Update on the operator resource without handling conflicts. Wrap this in a retry loop using the standard k8s.io/client-go/util/retry pattern to handle concurrent modifications.

Proposed fix
 import (
 	"context"
 	"fmt"
 	"testing"
 	"time"
@@
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/runtime"
+	"k8s.io/client-go/util/retry"
@@
 func UpdateUnsupportedConfig(t *testing.T, raw []byte) error {
 	operatorClient := GetOperator(t)
-	apiServerOperator, err := operatorClient.Get(context.TODO(), "cluster", metav1.GetOptions{})
-	if err != nil {
-		return err
-	}
-	apiServerOperator.Spec.UnsupportedConfigOverrides.Raw = raw
-	_, err = operatorClient.Update(context.TODO(), apiServerOperator, metav1.UpdateOptions{})
-	return err
+	return retry.RetryOnConflict(retry.DefaultBackoff, func() error {
+		apiServerOperator, err := operatorClient.Get(context.TODO(), "cluster", metav1.GetOptions{})
+		if err != nil {
+			return err
+		}
+		apiServerOperator.Spec.UnsupportedConfigOverrides.Raw = raw
+		_, err = operatorClient.Update(context.TODO(), apiServerOperator, metav1.UpdateOptions{})
+		return err
+	})
 }

Note: Use retry.DefaultBackoff (not DefaultRetry) to align with project convention and the documented recommendation for conflicts on actively-managed resources.

🤖 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 `@test/library/encryption/helpers.go` around lines 93 - 94, Wrap the single
operatorClient.Update call in a retry.RetryOnConflict loop using
retry.DefaultBackoff from k8s.io/client-go/util/retry to handle update
conflicts; inside the closure call operatorClient.Update(ctx, apiServerOperator,
metav1.UpdateOptions{}), and on conflict fetch the latest apiServerOperator (via
operatorClient.Get) and reapply your changes before retrying so the update
eventually succeeds. Ensure you import k8s.io/client-go/util/retry and keep
using metav1.UpdateOptions{} and the same context (context.TODO or passed ctx).

@tjungblu tjungblu closed this May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants