From 6a4258d5fdaa1b8ecd733cdfd55d13f8f7eb069b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Thu, 11 Mar 2021 12:43:34 +0800 Subject: [PATCH] cephadm: use split cgroup strategy for podman MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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: 胡玮文 (cherry picked from commit 1a76f4793ec96045b0fed5cd85b1a6b3dbcd732c) --- src/cephadm/cephadm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index f5a0fb1330ff..67a060c2842a 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -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 -- 2.47.3