From: Adam King Date: Tue, 25 Aug 2020 16:34:12 +0000 (-0400) Subject: cephadm: Change service type to forking via systemd X-Git-Tag: v16.1.0~1254^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e6792f306ab4d07251588fdca6ed3876ae3a092a;p=ceph.git cephadm: Change service type to forking via systemd Using Type=Forking and setting the PIDFile= directive is the supported configuration for running podman containers with systemd as it more accuractely models what is actually happening. Type=Simple assumes podman is the direct parent of the container processes which is not true. Fixes: https://tracker.ceph.com/issues/46654 Signed-off-by: Adam King --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 79d7c31ef119..7083b650e661 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -1826,6 +1826,16 @@ def get_container(fsid, daemon_type, daemon_id, if daemon_type == NFSGanesha.daemon_type: envs.extend(NFSGanesha.get_container_envs()) + # if using podman, set -d, --conmon-pidfile & --cidfile flags + # so service can have Type=Forking + if 'podman' in container_path: + runtime_dir = '/run' + container_args.extend(['-d', + '--conmon-pidfile', + runtime_dir + '/ceph-%s@%s.%s.service-pid' % (fsid, daemon_type, daemon_id), + '--cidfile', + runtime_dir + '/ceph-%s@%s.%s.service-cid' % (fsid, daemon_type, daemon_id)]) + return CephContainer( image=args.image, entrypoint=entrypoint, @@ -2241,6 +2251,13 @@ def install_base_units(fsid): def get_unit_file(fsid): # type: (str) -> str + extra_args = '' + if 'podman' in container_path: + extra_args = ('ExecStartPre=-/bin/rm -f /%t/%n-pid /%t/%n-cid\n' + 'ExecStopPost=-/bin/rm -f /%t/%n-pid /%t/%n-cid\n' + 'Type=forking\n' + 'PIDFile=/%t/%n-pid\n') + u = """# generated by cephadm [Unit] Description=Ceph %i for {fsid} @@ -2270,13 +2287,15 @@ TimeoutStartSec=120 TimeoutStopSec=120 StartLimitInterval=30min StartLimitBurst=5 - +{extra_args} [Install] WantedBy=ceph-{fsid}.target """.format( container_path=container_path, fsid=fsid, - data_dir=args.data_dir) + data_dir=args.data_dir, + extra_args=extra_args) + return u ##################################