Skip to content

Commit f0dd4d1

Browse files
author
saville
committed
Rename systemd v248 to systemd cgroup2
1 parent 008630f commit f0dd4d1

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,11 @@ the run step:
641641
# If found, systemd=true will be assumed.
642642
systemd: true/false
643643
# (Ignored when systemd is not enabled)
644-
# For systemd 248+, a read-write mount for /sys/fs/cgroup is required as well as a tmpfs mounted at /run, and
644+
# For cgroup v2, a read-write mount for /sys/fs/cgroup is required as well as a tmpfs mounted at /run, and
645645
# this flag enables this behavior
646-
# If this is ommitted, the image will be inspected for the label
647-
# 'BUILDRUNNER_SYSTEMD_V248' and that value will be used instead.
648-
systemd_v248: true/false
646+
# If this is omitted, the image will be inspected for the label
647+
# 'BUILDRUNNER_SYSTEMD_CGROUP2' and that value will be used instead.
648+
systemd_cgroup2: true/false
649649
650650
# Docker supports certain kernel capabilities, like 'SYS_ADMIN'.
651651
# see https://goo.gl/gTQrqW for more infromation on setting these.

buildrunner/config/models_step.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class RunAndServicesBase(StepTask):
104104
ports: Optional[Dict[int, Optional[int]]] = None
105105
pull: Optional[bool] = None
106106
systemd: Optional[bool] = None
107-
systemd_v248: Optional[bool] = None
107+
systemd_cgroup2: Optional[bool] = None
108108
containers: Optional[List[str]] = None
109109
caches: Optional[Dict[str, Union[str, List[str]]]] = None
110110

buildrunner/docker/runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def start(
150150
extra_hosts=None,
151151
containers=None,
152152
systemd: bool = False,
153-
systemd_v248: bool = False,
153+
systemd_cgroup2: bool = False,
154154
cap_add=None,
155155
privileged=False,
156156
): # pylint: disable=too-many-arguments,too-many-locals
@@ -178,7 +178,7 @@ def start(
178178
if systemd:
179179
# If we are running in a systemd context, the following 3 settings are necessary to
180180
# allow services to run.
181-
if systemd_v248:
181+
if systemd_cgroup2:
182182
volumes["/sys/fs/cgroup/buildrunner.scope"] = "/sys/fs/cgroup:rw"
183183
tmpfs["/run"] = ""
184184
cgroupns = "host"

buildrunner/steprunner/tasks/run.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ def _start_service_container(self, name, service: Service):
616616
working_dir=_cwd,
617617
containers=_containers,
618618
systemd=systemd,
619-
systemd_v248=self.is_systemd_v248(systemd, service, _image),
619+
systemd_cgroup2=self.is_systemd_cgroup2(systemd, service, _image),
620620
)
621621
self._service_links[cont_name] = name
622622

@@ -1025,7 +1025,7 @@ def run(self, context: dict): # pylint: disable=too-many-statements,too-many-br
10251025
)
10261026
# Figure out if we should be running systemd. Has to happen after docker pull
10271027
container_args["systemd"] = self.is_systemd(self.step, _run_image)
1028-
container_args["systemd_v248"] = self.is_systemd_v248(
1028+
container_args["systemd_cgroup2"] = self.is_systemd_cgroup2(
10291029
container_args["systemd"], self.step, _run_image
10301030
)
10311031

@@ -1164,16 +1164,16 @@ def is_systemd(self, run_service: RunAndServicesBase, image: str) -> bool:
11641164
return run_service.systemd
11651165
return self._get_label_is_truthy(image, "BUILDRUNNER_SYSTEMD")
11661166

1167-
def is_systemd_v248(
1167+
def is_systemd_cgroup2(
11681168
self, systemd: bool, run_service: RunAndServicesBase, image: str
11691169
) -> bool:
11701170
"""
1171-
Check if an image needs the changes for systemd v248+
1171+
Check if an image needs the changes for cgroup2
11721172
"""
11731173
if not systemd:
11741174
# Do not run any other checks if we are not using systemd at all
11751175
return False
11761176

1177-
if run_service.systemd_v248 is not None:
1178-
return run_service.systemd_v248
1179-
return self._get_label_is_truthy(image, "BUILDRUNNER_SYSTEMD_V248")
1177+
if run_service.systemd_cgroup2 is not None:
1178+
return run_service.systemd_cgroup2
1179+
return self._get_label_is_truthy(image, "BUILDRUNNER_SYSTEMD_CGROUP2")

tests/test-files/test-systemd.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ steps:
6161
run:
6262
systemd: true
6363
cmd: ps -p 1 -o cmd | tail -1 | grep /usr/sbin/init
64-
test-systemd-v248-on:
64+
test-systemd-cgroup2-on:
6565
build:
6666
dockerfile: |
67-
# Rocky linux 9 has 248+ installed
67+
# Rocky linux 9 has systemd 248+ installed
6868
FROM {{ DOCKER_REGISTRY }}/rockylinux:9.0
6969
RUN yum install -y procps-ng && yum clean all
7070
run:
7171
systemd: true
72-
systemd_v248: true
72+
systemd_cgroup2: true
7373
cmd: ps -p 1 -o cmd | tail -1 | grep /usr/sbin/init
7474

7575
test-systemd-on-built:
@@ -81,13 +81,13 @@ steps:
8181
run:
8282
cmd: ps -p 1 -o cmd | tail -1 | grep /usr/sbin/init
8383

84-
test-systemd-v248-on-built:
84+
test-systemd-cgroup2-on-built:
8585
build:
8686
dockerfile: |
8787
FROM {{ DOCKER_REGISTRY }}/rockylinux:9.0
8888
RUN yum install -y procps-ng && yum clean all
8989
LABEL BUILDRUNNER_SYSTEMD=1
90-
LABEL BUILDRUNNER_SYSTEMD_V248=1
90+
LABEL BUILDRUNNER_SYSTEMD_CGROUP2=1
9191
run:
9292
cmd: ps -p 1 -o cmd | tail -1 | grep /usr/sbin/init
9393

@@ -118,7 +118,7 @@ steps:
118118
image: {{ DOCKER_REGISTRY }}/rockylinux:8.5
119119
pull: false
120120
cmd: curl http://s1:8001 1>/dev/null 2>&1
121-
test-systemd-v248-service:
121+
test-systemd-cgroup2-service:
122122
run:
123123
services:
124124
s1:
@@ -127,7 +127,7 @@ steps:
127127
FROM {{ DOCKER_REGISTRY }}/rockylinux:9.0
128128
RUN yum -y install python3 procps-ng && yum clean all
129129
LABEL BUILDRUNNER_SYSTEMD=1
130-
LABEL BUILDRUNNER_SYSTEMD_V248=1
130+
LABEL BUILDRUNNER_SYSTEMD_CGROUP2=1
131131
systemd: true
132132
cmd: ps -p 1 -o cmd | tail -1 | grep /usr/sbin/init && python3 -m http.server 8001
133133
image: {{ DOCKER_REGISTRY }}/rockylinux:8.5

0 commit comments

Comments
 (0)