Skip to content

Commit 36d5763

Browse files
committed
Revert "Update CatalogSource Pod security context (#2782)"
This reverts commit 99b51e7. Signed-off-by: perdasilva <[email protected]>
1 parent 183bbfe commit 36d5763

File tree

37 files changed

+350
-2110
lines changed

37 files changed

+350
-2110
lines changed

Diff for: Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM quay.io/fedora/fedora:34-x86_64 as builder
22
LABEL stage=builder
33
WORKDIR /build
44

5-
# install dependencies and go 1.17
5+
# install dependencies and go 1.16
66

77
# copy just enough of the git repo to parse HEAD, used to record version in OLM binaries
88
RUN dnf update -y && dnf install -y bash make git mercurial jq wget && dnf upgrade -y

Diff for: pkg/controller/registry/reconciler/reconciler.go

+1-18
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,7 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name string, image string, saN
113113
pullPolicy = corev1.PullAlways
114114
}
115115

116-
// Security context
117116
readOnlyRootFilesystem := false
118-
allowPrivilegeEscalation := false
119-
runAsNonRoot := true
120-
121-
// See: https://github.com/operator-framework/operator-registry/blob/master/Dockerfile#L27
122-
runAsUser := int64(1001)
123117

124118
pod := &corev1.Pod{
125119
ObjectMeta: metav1.ObjectMeta{
@@ -173,23 +167,12 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name string, image string, saN
173167
},
174168
},
175169
SecurityContext: &corev1.SecurityContext{
176-
ReadOnlyRootFilesystem: &readOnlyRootFilesystem,
177-
AllowPrivilegeEscalation: &allowPrivilegeEscalation,
178-
Capabilities: &corev1.Capabilities{
179-
Drop: []corev1.Capability{"ALL"},
180-
},
170+
ReadOnlyRootFilesystem: &readOnlyRootFilesystem,
181171
},
182172
ImagePullPolicy: pullPolicy,
183173
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
184174
},
185175
},
186-
SecurityContext: &corev1.PodSecurityContext{
187-
RunAsNonRoot: &runAsNonRoot,
188-
RunAsUser: &runAsUser,
189-
SeccompProfile: &corev1.SeccompProfile{
190-
Type: corev1.SeccompProfileTypeRuntimeDefault,
191-
},
192-
},
193176
NodeSelector: map[string]string{
194177
"kubernetes.io/os": "linux",
195178
},

Diff for: pkg/controller/registry/reconciler/reconciler_test.go

+1-18
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,8 @@ func TestPullPolicy(t *testing.T) {
7979

8080
func TestPodContainerSecurityContext(t *testing.T) {
8181
expectedReadOnlyRootFilesystem := false
82-
expectedAllowPrivilegeEscalation := false
83-
expectedRunAsNonRoot := true
84-
expectedRunAsUser := int64(1001)
85-
8682
expectedContainerSecCtx := &corev1.SecurityContext{
87-
ReadOnlyRootFilesystem: &expectedReadOnlyRootFilesystem,
88-
AllowPrivilegeEscalation: &expectedAllowPrivilegeEscalation,
89-
Capabilities: &corev1.Capabilities{
90-
Drop: []corev1.Capability{"ALL"},
91-
},
92-
}
93-
expectedPodSecCtx := &corev1.PodSecurityContext{
94-
RunAsNonRoot: &expectedRunAsNonRoot,
95-
RunAsUser: &expectedRunAsUser,
96-
SeccompProfile: &corev1.SeccompProfile{
97-
Type: corev1.SeccompProfileTypeRuntimeDefault,
98-
},
83+
ReadOnlyRootFilesystem: &expectedReadOnlyRootFilesystem,
9984
}
10085

10186
catsrc := &v1alpha1.CatalogSource{
@@ -107,9 +92,7 @@ func TestPodContainerSecurityContext(t *testing.T) {
10792

10893
gotPod := Pod(catsrc, "hello", "busybox", "", map[string]string{}, map[string]string{}, int32(0), int32(0))
10994
gotContainerSecCtx := gotPod.Spec.Containers[0].SecurityContext
110-
gotPodSecCtx := gotPod.Spec.SecurityContext
11195
require.Equal(t, expectedContainerSecCtx, gotContainerSecCtx)
112-
require.Equal(t, expectedPodSecCtx, gotPodSecCtx)
11396
}
11497

11598
func TestPodSchedulingOverrides(t *testing.T) {

Diff for: scripts/build_test_images.sh

+12-36
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,19 @@
11
#!/usr/bin/env bash
22

3-
set -e
4-
5-
CATALOG_DIR=./test/catalogs
6-
CATALOG_DOCKER=${CATALOG_DIR}/catalog.Dockerfile
7-
8-
# Given an image and a catalog name
9-
# This functions builds the image and pushes it to the repository
10-
function build_and_push() {
11-
IMG_NAME=$1
12-
CATALOG_NAME=$2
13-
docker build -t "${IMG_NAME}" -f "${CATALOG_DOCKER}" "${CATALOG_DIR}/${CATALOG_NAME}"
14-
docker push "${IMG_NAME}"
15-
}
16-
17-
# olmtest images
18-
193
# Busybox Operator Index Image
20-
catalogs=( 1.0.0 2.0.0 )
21-
for c in "${catalogs[@]}"; do
22-
build_and_push "quay.io/olmtest/busybox-dependencies-index:${c}-with-ListBundles-method" "busybox-${c}"
23-
done
24-
25-
# single bundle index
26-
catalogs=( pdb-v1 objects objects-upgrade-samename objects-upgrade-diffname )
27-
for c in "${catalogs[@]}"; do
28-
build_and_push "quay.io/olmtest/single-bundle-index:${c}" "single-bundle-index-${c}"
29-
done
4+
docker build -t quay.io/olmtest/busybox-bundle:1.0.0 ./test/images/busybox-index/busybox/1.0.0
5+
docker build -t quay.io/olmtest/busybox-bundle:2.0.0 ./test/images/busybox-index/busybox/2.0.0
306

31-
# catsrc-update-test catalogs
32-
catalogs=( old new related )
33-
for c in "${catalogs[@]}"; do
34-
build_and_push "quay.io/olmtest/catsrc-update-test:${c}" "catsrc-update-test-${c}"
35-
done
7+
docker build -t quay.io/olmtest/busybox-dependency-bundle:1.0.0 ./test/images/busybox-index/busybox-dependency/1.0.0
8+
docker build -t quay.io/olmtest/busybox-dependency-bundle:2.0.0 ./test/images/busybox-index/busybox-dependency/2.0.0
369

37-
# operator-framework images
10+
docker push quay.io/olmtest/busybox-bundle:1.0.0
11+
docker push quay.io/olmtest/busybox-bundle:2.0.0
12+
docker push quay.io/olmtest/busybox-dependency-bundle:1.0.0
13+
docker push quay.io/olmtest/busybox-dependency-bundle:2.0.0
3814

39-
# ci-index
40-
build_and_push quay.io/operator-framework/ci-index:latest "ci-index"
15+
opm index add --bundles quay.io/olmtest/busybox-dependency-bundle:1.0.0,quay.io/olmtest/busybox-bundle:1.0.0 --tag quay.io/olmtest/busybox-dependencies-index:1.0.0-with-ListBundles-method -c docker
16+
docker push quay.io/olmtest/busybox-dependencies-index:1.0.0-with-ListBundles-method
4117

42-
# webhook-operator-index
43-
build_and_push quay.io/operator-framework/webhook-operator-index:0.0.3 "webhook-operator-index-0.0.3"
18+
opm index add --bundles quay.io/olmtest/busybox-dependency-bundle:2.0.0,quay.io/olmtest/busybox-bundle:2.0.0 --tag quay.io/olmtest/busybox-dependencies-index:2.0.0-with-ListBundles-method --from-index quay.io/olmtest/busybox-dependencies-index:1.0.0-with-ListBundles-method -c docker
19+
docker push quay.io/olmtest/busybox-dependencies-index:2.0.0-with-ListBundles-method

Diff for: test/catalogs/busybox-1.0.0/busybox-dependency/catalog.json

-60
This file was deleted.

Diff for: test/catalogs/busybox-1.0.0/busybox/catalog.json

-54
This file was deleted.

Diff for: test/catalogs/busybox-2.0.0/busybox-dependency/catalog.json

-61
This file was deleted.

Diff for: test/catalogs/busybox-2.0.0/busybox/catalog.json

-55
This file was deleted.

Diff for: test/catalogs/catalog.Dockerfile

-14
This file was deleted.

0 commit comments

Comments
 (0)