Skip to content

[main] OCPBUGS-112332: monitortests: skip PodSecurityViolation invariant when OpenShiftPodSecurityAdmission is disabled - #31571

Open
openshift-cherrypick-robot wants to merge 1 commit into
openshift:mainfrom
openshift-cherrypick-robot:cherry-pick-31561-to-main
Open

[main] OCPBUGS-112332: monitortests: skip PodSecurityViolation invariant when OpenShiftPodSecurityAdmission is disabled#31571
openshift-cherrypick-robot wants to merge 1 commit into
openshift:mainfrom
openshift-cherrypick-robot:cherry-pick-31561-to-main

Conversation

@openshift-cherrypick-robot

@openshift-cherrypick-robot openshift-cherrypick-robot commented Aug 27, 2026

Copy link
Copy Markdown

This is an automated cherry-pick of #31561

/assign sdodson

Summary by CodeRabbit

  • Bug Fixes

    • Pod security audit results now correctly account for clusters where pod security enforcement is explicitly disabled.
    • Reports include observed violations when the related enforcement check is skipped.
    • Improved handling of missing, ambiguous, or version-specific cluster configuration.
  • Tests

    • Added coverage for enforcement enabled, disabled, and absent violation scenarios.
    • Added validation for feature-gate detection across cluster versions.

…curityAdmission is disabled

With the OpenShiftPodSecurityAdmission feature gate disabled, the PSA
label syncer runs in advising mode and no longer sets the
pod-security.kubernetes.io/enforce label on namespaces. Workloads that
key their security context off that label, such as OLM catalog registry
pods via getDefaultPodContextConfig, then run with a legacy security
context. The global PodSecurity audit configuration is not feature-gated
and stays at restricted:latest, so creating those pods stamps
pod-security.kubernetes.io/audit-violations annotations into the audit
log by design, and this zero-tolerance invariant fails every run.

Skip the invariant when the gate is explicitly disabled for the current
cluster version. Any error or ambiguity while reading the FeatureGate
keeps the invariant enforcing, and clusters with the gate enabled are
unaffected.
@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

Copy link
Copy Markdown

@openshift-cherrypick-robot: Detected clone of Jira Issue OCPBUGS-83412 with correct target version. Will retitle the PR to link to the clone.
/retitle [main] OCPBUGS-112332: monitortests: skip PodSecurityViolation invariant when OpenShiftPodSecurityAdmission is disabled

Details

In response to this:

This is an automated cherry-pick of #31561

/assign sdodson

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 changed the title [main] OCPBUGS-83412: monitortests: skip PodSecurityViolation invariant when OpenShiftPodSecurityAdmission is disabled [main] OCPBUGS-112332: monitortests: skip PodSecurityViolation invariant when OpenShiftPodSecurityAdmission is disabled Aug 27, 2026
@openshift-ci-robot openshift-ci-robot added jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 27, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@openshift-cherrypick-robot: This pull request references Jira Issue OCPBUGS-112332, which is invalid:

  • expected the bug to be in one of the following states: NEW, ASSIGNED, POST, but it is Verified instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

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

Details

In response to this:

This is an automated cherry-pick of #31561

/assign sdodson

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 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: openshift-cherrypick-robot
Once this PR has been reviewed and has the lgtm label, please assign petr-muller 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 commented Aug 27, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 4ba36d5b-8318-4217-a396-d3cda2bc08b1

📥 Commits

Reviewing files that changed from the base of the PR and between 987e9a7 and 1be5a1f.

📒 Files selected for processing (3)
  • pkg/monitortests/kubeapiserver/auditloganalyzer/handle_audit_violation.go
  • pkg/monitortests/kubeapiserver/auditloganalyzer/handle_audit_violation_test.go
  • pkg/monitortests/kubeapiserver/auditloganalyzer/monitortest.go

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


Walkthrough

The audit log analyzer now detects whether OpenShiftPodSecurityAdmission is disabled for the active FeatureGate version. It records this state during collection and skips PodSecurity violation JUnit failures when enforcement is disabled. Tests cover detection and reporting outcomes.

Changes

PSA audit validation

Layer / File(s) Summary
PSA detection and violation reporting
pkg/monitortests/kubeapiserver/auditloganalyzer/handle_audit_violation.go, pkg/monitortests/kubeapiserver/auditloganalyzer/handle_audit_violation_test.go
CreateJunits accepts the enforcement state and emits a skip result with the observed violation count when enforcement is disabled. FeatureGate detection resolves the desired or fallback history version. Tests cover enabled, disabled, mismatched, absent, and empty-violation cases.
Analyzer state and collection integration
pkg/monitortests/kubeapiserver/auditloganalyzer/monitortest.go
auditLogAnalyzer stores the PSA enforcement state. StartCollection initializes it and passes it to violation JUnit generation.

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

Merge Risk: ⚪ Minimal · up to 1be5a

This localized change updates monitor-test behavior for disabled OpenShift pod security admission and adds coverage; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant auditLogAnalyzer
  participant FeatureGateClient
  participant CreateJunits
  auditLogAnalyzer->>FeatureGateClient: determine PSA enforcement state
  FeatureGateClient-->>auditLogAnalyzer: return FeatureGate configuration
  auditLogAnalyzer->>CreateJunits: pass psaEnforcementDisabled
  CreateJunits-->>auditLogAnalyzer: produce failure or skipped JUnit result
Loading
🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. 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 identifies the main change: skip the PodSecurityViolation invariant when OpenShiftPodSecurityAdmission is disabled. The issue references add context without obscuring the change.
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 PASS. The pull request adds standard Go tests and table-driven t.Run cases, not Ginkgo It, Describe, Context, or When titles. All added test names and subtest names are static. Dynamic-looki…
Test Structure And Quality ✅ Passed PASS: The pull request adds ordinary testing/Testify unit tests, not Ginkgo It blocks. Each test covers one related behavior, and the table cases exercise one helper with different feature-gate st…
Microshift Test Compatibility ✅ Passed PASS: The pull request adds standard Go unit tests, not new Ginkgo e2e tests. The added file imports testing and testify, uses Test... functions and t.Run, and contains no It, Describe, `C…
Single Node Openshift (Sno) Test Compatibility ✅ Passed The check is not applicable. The pull request adds standard Go testing unit tests with Test... and t.Run; it adds no Ginkgo It, Describe, Context, or When e2e tests. The changed implemen…
Topology-Aware Scheduling Compatibility ✅ Passed PASS: The pull request changes only audit-log monitor logic and tests. The diff adds FeatureGate lookup and JUnit skip behavior. It adds no deployment, controller, or operator scheduling configuration…
Ote Binary Stdout Contract ✅ Passed PASS: The pull request adds no stdout writes in process-level code. The changed implementation uses fmt.Sprintf only to build JUnit messages and performs FeatureGate reads without logging. The only …
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PASS — The pull request adds standard Go testing unit tests, not new Ginkgo e2e tests. The changed files contain no Ginkgo DSL, IPv4 literals, IPv4-only parsing, external URLs, registry pulls, or pu…
No-Weak-Crypto ✅ Passed PASS: The pull request adds FeatureGate lookup, JUnit skip logic, and tests only. The exact diff introduces no MD5, SHA1, DES, 3DES, RC4, Blowfish, ECB, custom cryptography, or secret/token comparison…
Container-Privileges ✅ Passed The pull request changes only three Go files under the audit log analyzer. The diff adds no container or Kubernetes manifest and no added line contains privileged, hostPID, hostNetwork, `hostIPC…
No-Sensitive-Data-In-Logs ✅ Passed No sensitive-data logging was introduced. The new skip message contains only the feature-gate name, a violation count, and a generic reference to the audit log. The existing failure output still inclu…
Full details: Stable And Deterministic Test Names

Explanation

PASS. The pull request adds standard Go tests and table-driven t.Run cases, not Ginkgo It, Describe, Context, or When titles. All added test names and subtest names are static. Dynamic-looking values such as the namespace are used only in test data, not test titles. The generated JUnit test name is also a fixed string.

Full details: Test Structure And Quality

Explanation

PASS: The pull request adds ordinary testing/Testify unit tests, not Ginkgo It blocks. Each test covers one related behavior, and the table cases exercise one helper with different feature-gate states. The tests use an in-memory fake config client and create no cluster resources, so BeforeEach/AfterEach cleanup and cluster-operation timeouts do not apply. They contain no Eventually or Consistently waits. The tests follow the existing package pattern of standard Go tests with Testify assertions, and the key behavior assertions include diagnostic messages.

Full details: Microshift Test Compatibility

Explanation

PASS: The pull request adds standard Go unit tests, not new Ginkgo e2e tests. The added file imports testing and testify, uses Test... functions and t.Run, and contains no It, Describe, Context, or When registrations. The MicroShift Test Compatibility check therefore does not apply. The FeatureGate and ClusterVersion references are in unit-test fakes and monitor implementation code, not in a new Ginkgo e2e test.

Full details: Single Node Openshift (Sno) Test Compatibility

Explanation

The check is not applicable. The pull request adds standard Go testing unit tests with Test... and t.Run; it adds no Ginkgo It, Describe, Context, or When e2e tests. The changed implementation also contains no multi-node or HA test assumptions.

Full details: Topology-Aware Scheduling Compatibility

Explanation

PASS: The pull request changes only audit-log monitor logic and tests. The diff adds FeatureGate lookup and JUnit skip behavior. It adds no deployment, controller, or operator scheduling configuration. The changed hunks contain no affinity, topology spread, replica, node selector, toleration, PDB, or control-plane scheduling constraints. Therefore, the topology-aware scheduling check is not applicable.

Full details: Ote Binary Stdout Contract

Explanation

PASS: The pull request adds no stdout writes in process-level code. The changed implementation uses fmt.Sprintf only to build JUnit messages and performs FeatureGate reads without logging. The only fmt.Printf calls found in monitortest.go are pre-existing lines outside the changed hunks. No klog, log, RunSpecs, suite hooks, TestMain, init, or os.Stdout usage was added.

Full details: Ipv6 And Disconnected Network Test Compatibility

Explanation

PASS — The pull request adds standard Go testing unit tests, not new Ginkgo e2e tests. The changed files contain no Ginkgo DSL, IPv4 literals, IPv4-only parsing, external URLs, registry pulls, or public-host connectivity. The Kubernetes FeatureGate lookup is cluster-internal configuration access and does not match a stated failure condition.

Full details: No-Weak-Crypto

Explanation

PASS: The pull request adds FeatureGate lookup, JUnit skip logic, and tests only. The exact diff introduces no MD5, SHA1, DES, 3DES, RC4, Blowfish, ECB, custom cryptography, or secret/token comparisons. No weak-crypto usage is present in the changed files.

Full details: Container-Privileges

Explanation

The pull request changes only three Go files under the audit log analyzer. The diff adds no container or Kubernetes manifest and no added line contains privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, or allowPrivilegeEscalation. The custom check has no applicable failure condition.

Full details: No-Sensitive-Data-In-Logs

Explanation

No sensitive-data logging was introduced. The new skip message contains only the feature-gate name, a violation count, and a generic reference to the audit log. The existing failure output still includes audit ID, resource, namespace, username, and violation text, but that output is unchanged from the parent revision. The new tests use synthetic service-account data.

  • Fix all pre-merge checks with AI
✨ 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 review from p0lyn0mial and sjenning August 27, 2026 12:46
@sdodson

sdodson commented Aug 27, 2026

Copy link
Copy Markdown
Member

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 27, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@sdodson: This pull request references Jira Issue OCPBUGS-112332, 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.1.0) matches configured target version for branch (5.1.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (xxia@redhat.com), skipping review request.

Details

In response to this:

/jira refresh

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

@sdodson

sdodson commented Aug 27, 2026

Copy link
Copy Markdown
Member

/hold
This is forward porting the change from release-5.0 where @ibihim got a quick hack in to unblock things but would like to put together a more refined long term fix. If we don't have the more refined fix by September 04 2026 we will move forward with this and assume the more refined fix will apply atop this change / revert this change if necessary.

@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 Aug 27, 2026
@openshift-ci

openshift-ci Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@openshift-cherrypick-robot: 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-aws-ovn-microshift 1be5a1f link true /test e2e-aws-ovn-microshift
ci/prow/e2e-aws-ovn-microshift-serial 1be5a1f link true /test e2e-aws-ovn-microshift-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.

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/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. 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.

4 participants