]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: use split cgroup strategy for podman
author胡玮文 <huww98@outlook.com>
Thu, 11 Mar 2021 04:43:34 +0000 (12:43 +0800)
committerSage Weil <sage@newdream.net>
Fri, 23 Apr 2021 12:24:13 +0000 (07:24 -0500)
Since systemd will create a cgroup for each service, we can instruct podman to
just split the current cgroup into sub-cgroups. This enables system admins to
use resource control features from systemd.

Signed-off-by: 胡玮文 <huww98@outlook.com>
(cherry picked from commit 1a76f4793ec96045b0fed5cd85b1a6b3dbcd732c)

src/cephadm/cephadm

index f5a0fb1330ffb6663ef2ad057356f2da924c4b6a..67a060c2842a534c9601878efe5a4c1efad04a03 100755 (executable)
@@ -66,6 +66,7 @@ LOG_DIR_MODE = 0o770
 DATA_DIR_MODE = 0o700
 CONTAINER_INIT = True
 MIN_PODMAN_VERSION = (2, 0, 2)
+CGROUPS_SPLIT_PODMAN_VERSION = (2, 1, 0)
 CUSTOM_PS1 = r'[ceph: \u@\h \W]\$ '
 DEFAULT_TIMEOUT = None  # in seconds
 DEFAULT_RETRY = 15
@@ -2477,6 +2478,8 @@ def get_container(ctx: CephadmContext,
             '--cidfile',
             runtime_dir + '/ceph-%s@%s.%s.service-cid' % (fsid, daemon_type, daemon_id),
         ])
+        if ctx.container_engine.version >= CGROUPS_SPLIT_PODMAN_VERSION:
+            container_args.append('--cgroups=split')
 
     return CephContainer(
         ctx,
@@ -2992,6 +2995,8 @@ def get_unit_file(ctx, fsid):
                       'ExecStopPost=-/bin/rm -f /%t/%n-pid /%t/%n-cid\n'
                       'Type=forking\n'
                       'PIDFile=/%t/%n-pid\n')
+        if ctx.container_engine.version >= CGROUPS_SPLIT_PODMAN_VERSION:
+            extra_args += 'Delegate=yes\n'
 
     docker = isinstance(ctx.container_engine, Docker)
     u = """# generated by cephadm