mirror of
https://github.com/ceph/ceph
synced 2025-02-24 03:27:10 +00:00
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 <adking@redhat.com>
This commit is contained in:
parent
26f231f60a
commit
e6792f306a
@ -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
|
||||
|
||||
##################################
|
||||
|
Loading…
Reference in New Issue
Block a user