|
| 1 | +:_content-type: PROCEDURE |
| 2 | +[id="oadp-restic-restore-failing-psa-policy_{context}"] |
| 3 | += Restic restore partially failing on OCP 4.14 due to changed PSA policy |
| 4 | + |
| 5 | +{ocp} 4.14 enforces a Pod Security Admission (PSA) policy that can hinder the readiness of pods during a Restic restore process. |
| 6 | + |
| 7 | +If a `SecurityContextConstraints` (SCC) resource is not found when a pod is created, and the PSA policy on the pod is not set up to meet the required standards, pod admission is denied. |
| 8 | + |
| 9 | +This issue arises due to the resource restore order of Velero. |
| 10 | + |
| 11 | +.Sample error |
| 12 | +[source,text] |
| 13 | +---- |
| 14 | +\"level=error\" in line#2273: time=\"2023-06-12T06:50:04Z\" |
| 15 | +level=error msg=\"error restoring mysql-869f9f44f6-tp5lv: pods\\\ |
| 16 | +"mysql-869f9f44f6-tp5lv\\\" is forbidden: violates PodSecurity\\\ |
| 17 | +"restricted:v1.24\\\": privil eged (container \\\"mysql\\\ |
| 18 | +" must not set securityContext.privileged=true), |
| 19 | +allowPrivilegeEscalation != false (containers \\\ |
| 20 | +"restic-wait\\\", \\\"mysql\\\" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (containers \\\ |
| 21 | +"restic-wait\\\", \\\"mysql\\\" must set securityContext.capabilities.drop=[\\\"ALL\\\"]), seccompProfile (pod or containers \\\ |
| 22 | +"restic-wait\\\", \\\"mysql\\\" must set securityContext.seccompProfile.type to \\\ |
| 23 | +"RuntimeDefault\\\" or \\\"Localhost\\\")\" logSource=\"/remote-source/velero/app/pkg/restore/restore.go:1388\" restore=openshift-adp/todolist-backup-0780518c-08ed-11ee-805c-0a580a80e92c\n |
| 24 | +velero container contains \"level=error\" in line#2447: time=\"2023-06-12T06:50:05Z\" |
| 25 | +level=error msg=\"Namespace todolist-mariadb, |
| 26 | +resource restore error: error restoring pods/todolist-mariadb/mysql-869f9f44f6-tp5lv: pods \\\ |
| 27 | +"mysql-869f9f44f6-tp5lv\\\" is forbidden: violates PodSecurity \\\"restricted:v1.24\\\": privileged (container \\\ |
| 28 | +"mysql\\\" must not set securityContext.privileged=true), |
| 29 | +allowPrivilegeEscalation != false (containers \\\ |
| 30 | +"restic-wait\\\",\\\"mysql\\\" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (containers \\\ |
| 31 | +"restic-wait\\\", \\\"mysql\\\" must set securityContext.capabilities.drop=[\\\"ALL\\\"]), seccompProfile (pod or containers \\\ |
| 32 | +"restic-wait\\\", \\\"mysql\\\" must set securityContext.seccompProfile.type to \\\ |
| 33 | +"RuntimeDefault\\\" or \\\"Localhost\\\")\" |
| 34 | +logSource=\"/remote-source/velero/app/pkg/controller/restore_controller.go:510\" |
| 35 | +restore=openshift-adp/todolist-backup-0780518c-08ed-11ee-805c-0a580a80e92c\n]", |
| 36 | +---- |
| 37 | + |
| 38 | +.Solution |
| 39 | + |
| 40 | +. In your DPA custom resource (CR), check or set the `restore-resource-priorities` field on the Velero server to ensure that `securitycontextconstraints` is listed in order before `pods` in the list of resources: |
| 41 | ++ |
| 42 | +[source,terminal] |
| 43 | +---- |
| 44 | +$ oc get dpa -o yaml |
| 45 | +---- |
| 46 | ++ |
| 47 | +.Example DPA CR |
| 48 | +[source,yaml] |
| 49 | +---- |
| 50 | +# ... |
| 51 | +configuration: |
| 52 | + restic: |
| 53 | + enable: true |
| 54 | + velero: |
| 55 | + args: |
| 56 | + restore-resource-priorities: 'securitycontextconstraints,customresourcedefinitions,namespaces,storageclasses,volumesnapshotclass.snapshot.storage.k8s.io,volumesnapshotcontents.snapshot.storage.k8s.io,volumesnapshots.snapshot.storage.k8s.io,datauploads.velero.io,persistentvolumes,persistentvolumeclaims,serviceaccounts,secrets,configmaps,limitranges,pods,replicasets.apps,clusterclasses.cluster.x-k8s.io,endpoints,services,-,clusterbootstraps.run.tanzu.vmware.com,clusters.cluster.x-k8s.io,clusterresourcesets.addons.cluster.x-k8s.io' <1> |
| 57 | + defaultPlugins: |
| 58 | + - gcp |
| 59 | + - openshift |
| 60 | +---- |
| 61 | +<1> If you have an existing restore resource priority list, ensure you combine that existing list with the complete list. |
| 62 | + |
| 63 | +. Ensure that the security standards for the application pods are aligned, as provided in link:https://access.redhat.com/solutions/7002730[Fixing PodSecurity Admission warnings for deployments], to prevent deployment warnings. If the application is not aligned with security standards, an error can occur regardless of the SCC. |
| 64 | + |
| 65 | +[NOTE] |
| 66 | +==== |
| 67 | +This solution is temporary, and ongoing discussions are in progress to address it. |
| 68 | +==== |
| 69 | + |
| 70 | + |
| 71 | +[role="_additional-resources"] |
| 72 | +.Additional resources |
| 73 | + |
| 74 | +* link:https://access.redhat.com/solutions/7002730[Fixing PodSecurity Admission warnings for deployments] |
0 commit comments