From 930a7469b9c0e7aa9c58b30ab111802ae106e4cb Mon Sep 17 00:00:00 2001 From: Jan Pazdziora Date: Wed, 20 Mar 2024 08:44:02 +0100 Subject: [PATCH] On cgroup v1 systems, assume hybrid setup and try /sys/fs/cgroup/unified. --- tests/freeipa-k3s.yaml.cgroups-v1.patch | 4 ++-- tests/freeipa-k3s.yaml.shm.patch | 4 ++-- tests/freeipa-replica-k3s.yaml.cgroups-v1.patch | 6 +++--- tests/run-master-and-replica.sh | 6 +++++- tests/run-partial-tests.sh | 7 ++++++- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/freeipa-k3s.yaml.cgroups-v1.patch b/tests/freeipa-k3s.yaml.cgroups-v1.patch index 774fd112..9e5ea7f2 100644 --- a/tests/freeipa-k3s.yaml.cgroups-v1.patch +++ b/tests/freeipa-k3s.yaml.cgroups-v1.patch @@ -6,7 +6,7 @@ mountPath: /data + - name: cgroups + mountPath: /sys/fs/cgroup -+ readOnly: true ++ readOnly: false ports: - containerPort: 80 protocol: TCP @@ -16,4 +16,4 @@ claimName: freeipa-data-pvc + - name: cgroups + hostPath: -+ path: /sys/fs/cgroup ++ path: /sys/fs/cgroup/unified diff --git a/tests/freeipa-k3s.yaml.shm.patch b/tests/freeipa-k3s.yaml.shm.patch index c1fe9559..a2cd6a41 100644 --- a/tests/freeipa-k3s.yaml.shm.patch +++ b/tests/freeipa-k3s.yaml.shm.patch @@ -3,7 +3,7 @@ @@ -66,6 +66,8 @@ - name: cgroups mountPath: /sys/fs/cgroup - readOnly: true + readOnly: false + - mountPath: /dev/shm + name: dshm ports: @@ -12,7 +12,7 @@ @@ -104,3 +106,6 @@ - name: cgroups hostPath: - path: /sys/fs/cgroup + path: /sys/fs/cgroup/unified + - name: dshm + emptyDir: + medium: Memory diff --git a/tests/freeipa-replica-k3s.yaml.cgroups-v1.patch b/tests/freeipa-replica-k3s.yaml.cgroups-v1.patch index b9b77d66..841881b9 100644 --- a/tests/freeipa-replica-k3s.yaml.cgroups-v1.patch +++ b/tests/freeipa-replica-k3s.yaml.cgroups-v1.patch @@ -1,12 +1,12 @@ --- tests/freeipa-replica-k3s.yaml +++ tests/freeipa-replica-k3s.yaml -@@ -77,6 +77,9 @@ spec: +@@ -77,6 +77,8 @@ spec: volumeMounts: - name: freeipa-server-data mountPath: /data + - name: cgroups + mountPath: /sys/fs/cgroup -+ readOnly: true ++ readOnly: false ports: - containerPort: 80 protocol: TCP @@ -16,4 +16,4 @@ claimName: freeipa-replica-pvc + - name: cgroups + hostPath: -+ path: /sys/fs/cgroup ++ path: /sys/fs/cgroup/unified diff --git a/tests/run-master-and-replica.sh b/tests/run-master-and-replica.sh index c0f95eab..4c7fe515 100755 --- a/tests/run-master-and-replica.sh +++ b/tests/run-master-and-replica.sh @@ -89,7 +89,11 @@ function run_ipa_container() { fi else # cgroup v1 - OPTS="-v /sys/fs/cgroup:/sys/fs/cgroup:ro" + if [ -e /sys/fs/cgroup/unified ] ; then + OPTS="-v /sys/fs/cgroup/unified:/sys/fs/cgroup:rw" + else + OPTS="-v /sys/fs/cgroup:/sys/fs/cgroup:ro" + fi fi OPTS="$OPTS --sysctl net.ipv6.conf.all.disable_ipv6=0" fi diff --git a/tests/run-partial-tests.sh b/tests/run-partial-tests.sh index dbc22fb1..dde9b07c 100755 --- a/tests/run-partial-tests.sh +++ b/tests/run-partial-tests.sh @@ -31,7 +31,12 @@ function run_and_wait_for () { : fi else - OPTS="$OPTS -v /sys/fs/cgroup:/sys/fs/cgroup:ro" + # cgroup v1 + if [ -e /sys/fs/cgroup/unified ] ; then + OPTS="$OPTS -v /sys/fs/cgroup/unified:/sys/fs/cgroup:rw" + else + OPTS="$OPTS -v /sys/fs/cgroup:/sys/fs/cgroup:ro" + fi fi fi if [ -n "$seccomp" ] ; then