From: Sage Weil Date: Thu, 2 Apr 2020 23:36:39 +0000 (-0500) Subject: cephadm: create /var/run/ceph dir via unit.run, not unit file X-Git-Tag: v16.1.0~2698^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a3be5f2aca8ac8163906e3015740327440a375b1;p=ceph.git cephadm: create /var/run/ceph dir via unit.run, not unit file The systemd unit file is shared with non-ceph daemons, which (1) don't need the /var/run directory, and (2) are based on a uid/gid from a different container image, which means we can't figure out the right ceph uid/gid from them to set the ownership properly. Instead, put it in the unit.run file... and only for ceph daemons when we have the uid/gid we need. Fixes: https://tracker.ceph.com/issues/44894 Signed-off-by: Sage Weil --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 7d257a65447b..9d7d3abfa774 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -1646,6 +1646,10 @@ def deploy_daemon_units(fsid, uid, gid, daemon_type, daemon_id, c, prestart = nfs_ganesha.get_rados_grace_container('add') f.write(' '.join(prestart.run_cmd()) + '\n') + if daemon_type in Ceph.daemons: + install_path = find_program('install') + f.write('{install_path} -d -m0770 -o {uid} -g {gid} /var/run/ceph/{fsid}\n'.format(install_path=install_path, fsid=fsid, uid=uid, gid=gid)) + # container run command f.write(' '.join(c.run_cmd()) + '\n') os.fchmod(f.fileno(), 0o600) @@ -1686,7 +1690,7 @@ def deploy_daemon_units(fsid, uid, gid, daemon_type, daemon_id, c, # systemd install_base_units(fsid) - unit = get_unit_file(fsid, uid, gid) + unit = get_unit_file(fsid) unit_file = 'ceph-%s@.service' % (fsid) with open(args.unit_dir + '/' + unit_file + '.new', 'w') as f: f.write(unit) @@ -1823,9 +1827,8 @@ def install_base_units(fsid): } """ % fsid) -def get_unit_file(fsid, uid, gid): - # type: (str, int, int) -> str - install_path = find_program('install') +def get_unit_file(fsid): + # type: (str) -> str u = """# generated by cephadm [Unit] Description=Ceph %i for {fsid} @@ -1845,7 +1848,6 @@ LimitNOFILE=1048576 LimitNPROC=1048576 EnvironmentFile=-/etc/environment ExecStartPre=-{container_path} rm ceph-{fsid}-%i -ExecStartPre=-{install_path} -d -m0770 -o {uid} -g {gid} /var/run/ceph/{fsid} ExecStart=/bin/bash {data_dir}/{fsid}/%i/unit.run ExecStop=-{container_path} stop ceph-{fsid}-%i ExecStopPost=-/bin/bash {data_dir}/{fsid}/%i/unit.poststop @@ -1861,10 +1863,7 @@ StartLimitBurst=5 WantedBy=ceph-{fsid}.target """.format( container_path=container_path, - install_path=install_path, fsid=fsid, - uid=uid, - gid=gid, data_dir=args.data_dir) return u