]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: Change service type to forking via systemd
authorAdam King <adking@redhat.com>
Tue, 25 Aug 2020 16:34:12 +0000 (12:34 -0400)
committerNathan Cutler <ncutler@suse.com>
Tue, 6 Oct 2020 09:40:32 +0000 (11:40 +0200)
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 <adking@redhat.com>
(cherry picked from commit e6792f306ab4d07251588fdca6ed3876ae3a092a)

src/cephadm/cephadm

index 6f1759d82b1c04cac5c2c7e783410e42cf9cad7e..d79bd0f858df1fa9b88649a385a24f8930b3a2cf 100755 (executable)
@@ -1825,6 +1825,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,
@@ -2239,6 +2249,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}
@@ -2268,13 +2285,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
 
 ##################################