Skip to content

OCPBUGS-86895: Ensure packageserver pod seccompProfile is always set - #1341

Open
tmshort wants to merge 1 commit into
openshift:mainfrom
tmshort:ocpbugs-86895-packageserver-seccomp
Open

OCPBUGS-86895: Ensure packageserver pod seccompProfile is always set#1341
tmshort wants to merge 1 commit into
openshift:mainfrom
tmshort:ocpbugs-86895-packageserver-seccomp

Conversation

@tmshort

@tmshort tmshort commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The openshift-operator-lifecycle-manager namespace enforces restricted:latest PodSecurity, requiring seccompProfile: RuntimeDefault on all pods.
  • The packageserver CSV template includes this field, but the cluster-stored CSV can diverge (created before the field was added, or via an upgrade race where OLM processes a cached pre-update CSV).
  • OLM faithfully reproduces whatever is in the cluster CSV, so the generated Deployment pod template is missing seccompProfile. On most clusters the restricted-v2 SCC mutating admission adds it before PSA validates — masking the bug. On OSD/ROSA Classic, PSA runs before SCC mutation, so pods are rejected and OLM enters a perpetual reinstall loop (observed at generation=716, revision=566).
  • Fix: explicitly enforce seccompProfile: RuntimeDefault in ensureCSVHighAvailability, which runs on every PSM reconcile, making the field mandatory regardless of the stored CSV state.

Test plan

  • Three new unit test cases added to TestEnsureCSV: missing seccompProfile (HA topology), missing seccompProfile (single-replica topology), nil SecurityContext
  • go test ./pkg/package-server-manager/... passes
  • Backport to all active release branches (4.18, 4.19, 4.20, ...)

Fixes: https://issues.redhat.com/browse/OCPBUGS-86895

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved deployment security by ensuring pods use the RuntimeDefault seccomp profile.
    • Automatically creates or restores missing pod security configuration.
    • Applies these corrections consistently to highly available and single-replica deployments.
    • Deployments are now marked for update when security settings require correction.

@openshift-ci-robot

Copy link
Copy Markdown

@tmshort: Jira Issue OCPBUGS-86895 is in a security level that is not in the allowed security levels for this repo.
Allowed security levels for this repo are:

  • Red Hat Employee
  • Red Hat Partner
  • default
Details

In response to this:

Summary

  • The openshift-operator-lifecycle-manager namespace enforces restricted:latest PodSecurity, requiring seccompProfile: RuntimeDefault on all pods.
  • The packageserver CSV template includes this field, but the cluster-stored CSV can diverge (created before the field was added, or via an upgrade race where OLM processes a cached pre-update CSV).
  • OLM faithfully reproduces whatever is in the cluster CSV, so the generated Deployment pod template is missing seccompProfile. On most clusters the restricted-v2 SCC mutating admission adds it before PSA validates — masking the bug. On OSD/ROSA Classic, PSA runs before SCC mutation, so pods are rejected and OLM enters a perpetual reinstall loop (observed at generation=716, revision=566).
  • Fix: explicitly enforce seccompProfile: RuntimeDefault in ensureCSVHighAvailability, which runs on every PSM reconcile, making the field mandatory regardless of the stored CSV state.

Test plan

  • Three new unit test cases added to TestEnsureCSV: missing seccompProfile (HA topology), missing seccompProfile (single-replica topology), nil SecurityContext
  • go test ./pkg/package-server-manager/... passes
  • Backport to all active release branches (4.18, 4.19, 4.20, ...)

Fixes: https://issues.redhat.com/browse/OCPBUGS-86895

🤖 Generated with Claude Code

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

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 597657eb-2108-4ae5-bd80-0859970fb513

📥 Commits

Reviewing files that changed from the base of the PR and between 07524d1 and dacdc2c.

📒 Files selected for processing (2)
  • pkg/package-server-manager/config.go
  • pkg/package-server-manager/controller_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/package-server-manager/config.go
  • pkg/package-server-manager/controller_test.go

Walkthrough

The package server manager now enforces a pod-level RuntimeDefault seccomp profile. Tests cover missing seccomp profiles and nil pod security contexts for highly available and single-replica deployments.

Changes

Seccomp profile enforcement

Layer / File(s) Summary
RuntimeDefault reconciliation
pkg/package-server-manager/config.go, pkg/package-server-manager/controller_test.go
ensureCSVHighAvailability creates missing security objects and restores the RuntimeDefault seccomp profile. Tests verify the behavior for highly available and single-replica configurations.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: perdasilva, grokspawn

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 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 bug and the main change: ensuring the packageserver pod always sets seccompProfile to RuntimeDefault.
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 Added test titles are static literals: MissingSeccompProfile and NilPodSecurityContext; no generated values, timestamps, nodes, namespaces, or IPs appear in the titles.
Test Structure And Quality ✅ Passed Changed tests use table-driven testify subtests with in-memory CSV fixtures. Each case covers one repair scenario, with no cluster resources, waits, or cleanup needs.
Microshift Test Compatibility ✅ Passed The changes add standard Go unit-test cases in controller_test.go, not new Ginkgo e2e tests; the MicroShift API compatibility check does not apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR adds standard Go table-driven unit tests under TestEnsureCSV, not Ginkgo e2e tests. They make no runtime SNO or multi-node cluster assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed The diff adds only pod seccomp security-context enforcement and tests. It adds no scheduling constraint; existing required anti-affinity and maxUnavailable=1 are unchanged.
Ote Binary Stdout Contract ✅ Passed The PR changes only package-server-manager files; no OTE files or process-level stdout writes were added, and tests-extension/cmd/main.go has no direct stdout print calls.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The added tests are standard Go table-driven unit tests using testing.T; they create CSV objects locally and contain no IPv4 assumptions or external network access.
No-Weak-Crypto ✅ Passed The PR diff adds only Kubernetes seccomp security-context logic and tests; no weak algorithms, custom crypto, or secret/token comparisons are present.
Container-Privileges ✅ Passed The PR adds only pod SeccompProfile RuntimeDefault enforcement. The diff adds no privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, root, or allowPrivilegeEscalation:true setting.
No-Sensitive-Data-In-Logs ✅ Passed The commit adds no logging calls or log arguments. Added code only sets SeccompProfile, and test names contain no sensitive data.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@tmshort

tmshort commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

/jira refresh

@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. labels Jul 31, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@tmshort: This pull request references Jira Issue OCPBUGS-86895, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

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:

/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-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Jul 31, 2026
@openshift-ci
openshift-ci Bot requested review from grokspawn and perdasilva July 31, 2026 18:04
@openshift-ci

openshift-ci Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tmshort

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 31, 2026
@tmshort

tmshort commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

/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 Jul 31, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@tmshort: This pull request references Jira Issue OCPBUGS-86895, 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 ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)
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-ci-robot

Copy link
Copy Markdown

@tmshort: This pull request references Jira Issue OCPBUGS-86895, 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:

Summary

  • The openshift-operator-lifecycle-manager namespace enforces restricted:latest PodSecurity, requiring seccompProfile: RuntimeDefault on all pods.
  • The packageserver CSV template includes this field, but the cluster-stored CSV can diverge (created before the field was added, or via an upgrade race where OLM processes a cached pre-update CSV).
  • OLM faithfully reproduces whatever is in the cluster CSV, so the generated Deployment pod template is missing seccompProfile. On most clusters the restricted-v2 SCC mutating admission adds it before PSA validates — masking the bug. On OSD/ROSA Classic, PSA runs before SCC mutation, so pods are rejected and OLM enters a perpetual reinstall loop (observed at generation=716, revision=566).
  • Fix: explicitly enforce seccompProfile: RuntimeDefault in ensureCSVHighAvailability, which runs on every PSM reconcile, making the field mandatory regardless of the stored CSV state.

Test plan

  • Three new unit test cases added to TestEnsureCSV: missing seccompProfile (HA topology), missing seccompProfile (single-replica topology), nil SecurityContext
  • go test ./pkg/package-server-manager/... passes
  • Backport to all active release branches (4.18, 4.19, 4.20, ...)

Fixes: https://issues.redhat.com/browse/OCPBUGS-86895

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
  • Improved high-availability deployment configuration by ensuring pods use the RuntimeDefault seccomp profile.
  • Automatically restores missing or incomplete pod security settings.
  • Added coverage for correcting security configuration in both highly available and single-replica deployments.

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

🧹 Nitpick comments (1)
pkg/package-server-manager/controller_test.go (1)

273-293: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for an existing non-RuntimeDefault profile.

The new cases cover a nil SeccompProfile and a nil PodSecurityContext. They do not exercise the existing-profile branch at Line 160. Add one table case with a non-RuntimeDefault profile and assert that reconciliation reports modified and restores RuntimeDefault.

🤖 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 `@pkg/package-server-manager/controller_test.go` around lines 273 - 293, Add a
table-driven test case in the reconciliation test cases for an existing non-
RuntimeDefault SeccompProfile, using the relevant helper to construct that
profile. Set the expected result to modified with no error, and define
expectedCSV with the same configuration but a RuntimeDefault profile, covering
the existing-profile branch alongside the nil-profile cases.
🤖 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.

Nitpick comments:
In `@pkg/package-server-manager/controller_test.go`:
- Around line 273-293: Add a table-driven test case in the reconciliation test
cases for an existing non- RuntimeDefault SeccompProfile, using the relevant
helper to construct that profile. Set the expected result to modified with no
error, and define expectedCSV with the same configuration but a RuntimeDefault
profile, covering the existing-profile branch alongside the nil-profile cases.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 46bb4f81-beb5-403f-89ed-b3aebeca5015

📥 Commits

Reviewing files that changed from the base of the PR and between 7687017 and 07524d1.

📒 Files selected for processing (2)
  • pkg/package-server-manager/config.go
  • pkg/package-server-manager/controller_test.go

The openshift-operator-lifecycle-manager namespace enforces
pod-security.kubernetes.io/enforce: restricted:latest, which requires
every pod to have securityContext.seccompProfile.type set to
RuntimeDefault or Localhost.

The packageserver CSV template (pkg/manifests/csv.yaml) includes the
correct pod-level seccompProfile, but there is a window where the
cluster-stored CSV can diverge from the template:

- The cluster CSV may have been created before seccompProfile was added
  to the template (commit 26b2061), leaving it absent in the stored
  object.
- During OLM upgrades, a race between the PSM and OLM can cause OLM to
  process a cached, pre-update version of the CSV and generate a
  Deployment without the field.

In both cases OLM faithfully reproduces whatever is in the cluster CSV,
so the generated Deployment pod template is missing seccompProfile. On
most clusters this is masked: OpenShift's restricted-v2 SCC mutating
admission adds seccompProfile to pods before PSA validates them. On
OSD/ROSA Classic the managed admission chain processes PSA before (or
independently of) SCC mutation, so pods are rejected, the Deployment
stays unhealthy, and OLM enters a perpetual cert-rotation reinstall loop
(observed at generation=716, revision=566).

Fix: explicitly enforce seccompProfile in ensureCSVHighAvailability,
which runs on every PSM reconcile. This makes the field mandatory
regardless of what the stored CSV contains, closes the upgrade race
window, and does not depend on the reflect.DeepEqual full-spec
comparison in ensureCSV catching a single missing field among many.

Add three test cases covering: missing seccompProfile with HA topology,
missing seccompProfile with single-replica topology, and a nil
SecurityContext (defensive nil-safety).

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Todd Short <tshort@redhat.com>
@tmshort
tmshort force-pushed the ocpbugs-86895-packageserver-seccomp branch from 07524d1 to dacdc2c Compare July 31, 2026 19:17
@openshift-ci

openshift-ci Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@tmshort: 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/unit-olm 07524d1 link true /test unit-olm

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

approved Indicates a PR has been approved by an approver from all required OWNERS files. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants