Skip to content

OCPBUGS-86044: Fix oc adm policy SCC test race on multi-master clusters#31221

Open
tchap wants to merge 1 commit into
openshift:mainfrom
tchap:OCPBUGS-86044/fix-scc-policy-test-race
Open

OCPBUGS-86044: Fix oc adm policy SCC test race on multi-master clusters#31221
tchap wants to merge 1 commit into
openshift:mainfrom
tchap:OCPBUGS-86044/fix-scc-policy-test-race

Conversation

@tchap
Copy link
Copy Markdown
Contributor

@tchap tchap commented May 27, 2026

Batch user and service account subjects into single oc invocations to eliminate cross-master watch cache races, and poll with Eventually to wait for cache propagation between adds and removes.

Summary by CodeRabbit

  • Tests
    • Updated CLI admin policy tests to use asynchronous polling for improved reliability when verifying cluster role binding changes.

Note: This release contains test improvements only. No user-facing functionality has changed.

Batch user and service account subjects into single oc invocations
to eliminate cross-master watch cache races, and poll with Eventually
to wait for cache propagation between adds and removes.
@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels May 27, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@tchap: This pull request references Jira Issue OCPBUGS-86044, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Batch user and service account subjects into single oc invocations to eliminate cross-master watch cache races, and poll with Eventually to wait for cache propagation between adds and removes.

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Walkthrough

This PR updates the SCC policy tests in test/extended/cli/admin.go to replace synchronous assertions with asynchronous polling. Both SCC addition and removal operations now use Eventually to repeatedly query the clusterrolebinding YAML until the expected state is reached, improving test reliability.

Changes

SCC Policy CLI Test Async Polling

Layer / File(s) Summary
Add and remove SCC binding async verification
test/extended/cli/admin.go
SCC addition test now adds the privileged SCC to fake-user with explicit -z fake-sa and polls the clusterrolebinding YAML until it contains all expected subjects. SCC removal test removes the SCC with -z fake-sa and polls until the binding no longer contains the subjects, replacing the previous immediate check and removal of 404 handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 10 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Test Structure And Quality ⚠️ Warning Test lacks error handling in removal polling (lines 227-233): if the clusterrolebinding is deleted, the Eventually callback returns error instead of treating it as terminal success, causing timeout. Handle "not found" errors in the removal Eventually callback by returning empty string for deleted bindings, allowing polling to succeed when subjects are removed.
Ipv6 And Disconnected Network Test Compatibility ⚠️ Warning Test "release extract image-references" in new file admin.go requires external connectivity to quay.io, failing in disconnected IPv6-only environments. Add [Skipped:Disconnected] to test name or use cluster-internal registries instead of quay.io.
✅ Passed checks (10 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 identifies the main change: fixing a race condition in the oc adm policy SCC test for multi-master clusters, which aligns with the changeset's focus on rewriting async polling logic and eliminating race conditions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 Test title "policy [apigroup:authorization.openshift.io][apigroup:user.openshift.io]" is stable, deterministic, and contains no dynamic values or generated suffixes.
Microshift Test Compatibility ✅ Passed All new tests use either protected apigroup tags for unavailable APIs or only standard Kubernetes APIs compatible with MicroShift.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR modifies existing Ginkgo e2e tests but does not add new tests. The check applies only to newly added tests, making it not applicable here.
Topology-Aware Scheduling Compatibility ✅ Passed This PR modifies only test code (test/extended/cli/admin.go), not deployment manifests, operator code, or controllers. No scheduling constraints are introduced.
Ote Binary Stdout Contract ✅ Passed All changes are contained within test blocks (It functions). File contains no process-level stdout writes; no fmt.Print, klog, or direct os.Stdout operations detected.

✏️ 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 deads2k and p0lyn0mial May 27, 2026 08:53
@openshift-ci-robot
Copy link
Copy Markdown

@tchap: This pull request references Jira Issue OCPBUGS-86044, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

Batch user and service account subjects into single oc invocations to eliminate cross-master watch cache races, and poll with Eventually to wait for cache propagation between adds and removes.

Summary by CodeRabbit

  • Tests
  • Updated CLI admin policy tests to use asynchronous polling for improved reliability when verifying cluster role binding changes.

Note: This release contains test improvements only. No user-facing functionality has changed.

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

openshift-ci Bot commented May 27, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tchap
Once this PR has been reviewed and has the lgtm label, please assign stbenjam 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

Copy link
Copy Markdown

@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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/extended/cli/admin.go`:
- Around line 225-233: The polling callback passed to Eventually that runs
oc.Run("get").Args("clusterrolebinding/system:openshift:scc:privileged", "-o",
"yaml").Output() must treat a "not found" error as a terminal success: if the
get command returns an error and the error message indicates the
ClusterRoleBinding is missing (e.g. contains "NotFound" or "not found"), return
an empty string and nil so Eventually stops; otherwise propagate the error as
before. Update the anonymous func used in the Eventually call to detect the
missing-binding error and convert it into a successful (empty, nil) response.
🪄 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 YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 83551d20-0e8b-46b7-91e3-5f5fe21302d8

📥 Commits

Reviewing files that changed from the base of the PR and between 355916d and 02600b3.

📒 Files selected for processing (1)
  • test/extended/cli/admin.go

Comment thread test/extended/cli/admin.go
@openshift-ci openshift-ci Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label May 27, 2026
@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 27, 2026

@tchap: 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-csi 02600b3 link true /test e2e-gcp-csi
ci/prow/e2e-metal-ipi-ovn-ipv6 02600b3 link true /test e2e-metal-ipi-ovn-ipv6

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.

// 2. the binding does not exists, if we removed all entities from the binding
o.Expect(out).To(o.ContainSubstring(`clusterrolebindings.rbac.authorization.k8s.io "system:openshift:scc:privileged" not found`))
}
o.Eventually(func() (string, error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It makes sense using Eventually if we have reasons for it. Maybe we should add documentation about this.

o.Expect(err).To(o.HaveOccurred())
o.Expect(out).To(o.ContainSubstring("error: rolebinding custom found for role view, not other"))

o.Expect(oc.Run("adm", "policy", "add-scc-to-user").Args("privileged", "fake-user").Execute()).To(o.Succeed())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it is better to keep the tests we have.

o.Expect(out).To(o.ContainSubstring("fake-sa"))
o.Expect(out).To(o.ContainSubstring("fake-group"))

o.Expect(oc.Run("adm", "policy", "remove-scc-from-user").Args("privileged", "fake-user").Execute()).To(o.Succeed())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same. We should keep it, unless this causes the race condition

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

Labels

jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants