Skip to content

Commit dc25cb0

Browse files
committed
Default to legacy PSA settings
Problem: OLM recently introduced a few changes to default to running its workloads in a restricted mode. As a part of these changes, catalogSources built with earlier versions of OPM will not run as expected unless the catalogSource yaml is configured to run in a legacy version. Unfortunately, these legacy catalogs cannot be ran in restricted namespaces, which includes the `olm` namespace which is used to define global catalogSources. Solution: Provide users ample time to convert to the new restricted fromat by defaulting to legacy restrictions and reclassify the `olm` namespace as a baseline privilege namespace. Signed-off-by: Alexander Greene <[email protected]>
1 parent c3340a3 commit dc25cb0

File tree

3 files changed

+44
-15
lines changed

3 files changed

+44
-15
lines changed

pkg/controller/registry/reconciler/reconciler.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,7 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name string, image string, saN
195195
},
196196
}
197197

198-
if source.Spec.GrpcPodConfig != nil {
199-
if source.Spec.GrpcPodConfig.SecurityContextConfig == operatorsv1alpha1.Restricted {
200-
addSecurityContext(pod, runAsUser)
201-
}
202-
} else {
198+
if source.Spec.GrpcPodConfig != nil && source.Spec.GrpcPodConfig.SecurityContextConfig == operatorsv1alpha1.Restricted {
203199
addSecurityContext(pod, runAsUser)
204200
}
205201

pkg/controller/registry/reconciler/reconciler_test.go

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,57 @@ func TestPodContainerSecurityContext(t *testing.T) {
8888
expectedContainerSecurityContext *corev1.SecurityContext
8989
}{
9090
{
91-
title: "NoSpecDefined/PodContainsSecurityConfigForPSARestricted",
91+
title: "NoSpecDefined/PodContainsSecurityConfigForPSALegacy",
9292
inputCatsrc: &v1alpha1.CatalogSource{
9393
ObjectMeta: metav1.ObjectMeta{
9494
Name: "test",
9595
Namespace: "testns",
9696
},
9797
},
98-
expectedContainerSecurityContext: &corev1.SecurityContext{
99-
ReadOnlyRootFilesystem: pointer.Bool(false),
100-
AllowPrivilegeEscalation: pointer.Bool(false),
101-
Capabilities: &corev1.Capabilities{
102-
Drop: []corev1.Capability{"ALL"},
98+
expectedContainerSecurityContext: nil,
99+
expectedSecurityContext: nil,
100+
},
101+
{
102+
title: "SpecDefined/NoGRPCPodConfig/PodContainsSecurityConfigForPSALegacy",
103+
inputCatsrc: &v1alpha1.CatalogSource{
104+
ObjectMeta: metav1.ObjectMeta{
105+
Name: "test",
106+
Namespace: "testns",
103107
},
108+
Spec: v1alpha1.CatalogSourceSpec{},
104109
},
105-
expectedSecurityContext: &corev1.PodSecurityContext{
106-
SeccompProfile: &corev1.SeccompProfile{Type: corev1.SeccompProfileTypeRuntimeDefault},
107-
RunAsUser: pointer.Int64(workloadUserID),
108-
RunAsNonRoot: pointer.Bool(true),
110+
expectedContainerSecurityContext: nil,
111+
expectedSecurityContext: nil,
112+
},
113+
{
114+
title: "SpecDefined/GRPCPodConfigDefined/PodContainsSecurityConfigForPSALegacy",
115+
inputCatsrc: &v1alpha1.CatalogSource{
116+
ObjectMeta: metav1.ObjectMeta{
117+
Name: "test",
118+
Namespace: "testns",
119+
},
120+
Spec: v1alpha1.CatalogSourceSpec{
121+
GrpcPodConfig: &v1alpha1.GrpcPodConfig{},
122+
},
123+
},
124+
expectedContainerSecurityContext: nil,
125+
expectedSecurityContext: nil,
126+
},
127+
{
128+
title: "SpecDefined/SecurityContextConfig:Legacy/PodContainsSecurityConfigForPSALegacy",
129+
inputCatsrc: &v1alpha1.CatalogSource{
130+
ObjectMeta: metav1.ObjectMeta{
131+
Name: "test",
132+
Namespace: "testns",
133+
},
134+
Spec: v1alpha1.CatalogSourceSpec{
135+
GrpcPodConfig: &v1alpha1.GrpcPodConfig{
136+
SecurityContextConfig: v1alpha1.Legacy,
137+
},
138+
},
109139
},
140+
expectedContainerSecurityContext: nil,
141+
expectedSecurityContext: nil,
110142
},
111143
{
112144
title: "SpecDefined/SecurityContextConfig:Restricted/PodContainsSecurityConfigForPSARestricted",

test/e2e/catalog_e2e_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
14511451
}).Should(Succeed())
14521452
})
14531453
It("The registry pod fails to become come up because of lack of permission", func() {
1454+
Skip("This test will not work until catalogSources run in restricted mode by default")
14541455
Eventually(func() (bool, error) {
14551456
podList, err := c.KubernetesInterface().CoreV1().Pods(ns.GetName()).List(context.TODO(), metav1.ListOptions{})
14561457
if err != nil {

0 commit comments

Comments
 (0)