]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: Change service type to forking via systemd 36800/head
authorAdam King <adking@redhat.com>
Tue, 25 Aug 2020 16:34:12 +0000 (12:34 -0400)
committerAdam King <adking@redhat.com>
Thu, 27 Aug 2020 19:10:20 +0000 (15:10 -0400)
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>
src/cephadm/cephadm

index 79d7c31ef119c021a132d1e036e8ee70b9a32eb6..7083b650e66186603a56104a151ccb841e5a688c 100755 (executable)
@@ -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
 
 ##################################