fix: pin CatalogSource pods to restricted-v2 SCC on OpenShift HCP#1332
fix: pin CatalogSource pods to restricted-v2 SCC on OpenShift HCP#1332TGPSKI wants to merge 2 commits into
Conversation
On HCP clusters, SCC admission evaluates against the creating user (the hosted control plane) rather than the pod's ServiceAccount. This broader access set allows customer-installed SCCs with MustRunAs to score as more restrictive than restricted-v2's MustRunAsRange, winning admission and mutating the pod to an unexpected UID. The UID mismatch causes permission denied errors on pre-baked cache directories (e.g. /tmp/cache/pogreb.v1/db/lock), crashing catalog pods. Add the openshift.io/required-scc annotation (GA since OCP 4.14, openshift/enhancements#1391) to pin SCC selection to restricted-v2 when securityContextConfig is Restricted. The annotation is a no-op on non-OpenShift clusters and respects user-provided overrides. Fixes: openshift#1331
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: TGPSKI The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe Pod reconciler now adds ChangesRestricted SCC annotation pinning
Sequence Diagram(s)Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 14 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (14 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @TGPSKI. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
/test |
|
@TGPSKI: Cannot trigger testing until a trusted user reviews the PR and leaves an DetailsIn response to this:
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. |
|
/ok-to-test |
Run `go mod tidy && go mod vendor` to update the vendored copy of reconciler.go to match the staging change from the previous commit.
|
/test verify-deps |
|
@TGPSKI: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
Summary
On ROSA HCP clusters, CatalogSource pods can be assigned a customer-installed SCC instead of
restricted-v2, causing the pod to run with an unexpected UID and crash withpermission deniederrors on pre-baked cache directories.This PR adds the
openshift.io/required-scc: restricted-v2annotation to CatalogSource pods whensecurityContextConfigisRestricted, pinning SCC selection and preventing custom SCCs from preempting admission.Problem
OpenShift's SCC admission selects the "most restrictive" SCC from the candidate set of the creating user. On HCP, the entity that creates catalog pods on the data plane has broader SCC access than the local
catalog-operatorServiceAccount on classic OpenShift — evidenced by thesecurity.openshift.io/validated-scc-subject-type: userannotation on affected pods.A custom SCC with
runAsUser.type: MustRunAs(single fixed UID) scores as more restrictive thanrestricted-v2'sMustRunAsRange. When such an SCC wins, it mutates the pod to a UID that differs from the image's expected UID (1001 perUSERdirective), resulting in:This does not reproduce on classic OpenShift — the same custom SCC installed on classic causes
restricted-v2to still win, consistent with the localcatalog-operatorSA not having access to customer-installed SCCs.Fix
Uses the
openshift.io/required-sccpod annotation (GA since OCP 4.14, openshift/enhancements#1391) to pin SCC selection torestricted-v2within the existingRestrictedsecurity context branch.Key properties:
!alreadySetcheck preserves any annotation passed through CatalogSource annotationsRestrictedbranch (PSA-labeled namespaces or explicitgrpcPodConfig.securityContextConfig: restricted)Test Plan
TestPodExtractContenttests updated to expect the new annotation in Restricted modeTestPodRequiredSCCAnnotationtest validates:pkg/controller/registry/reconciler/test suite passesReferences