ceph-daemon: /var/run/ceph -> /var/run/ceph/$fsid

This is better than having a single /var/run/ceph on the host with a
weird naming scheme.  Among other things, it means that we can access
the asok for any daemon for a given fsid from any container on the same
host with the same fsid (notably, a shell).

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2019-10-24 21:03:34 -05:00
parent 458f369f46
commit d23cf0113d

View File

@ -257,10 +257,6 @@ def get_daemon_args(fsid, daemon_type, daemon_id):
'--default-log-to-file=false',
'--default-log-to-stderr=true',
]
if fsid and daemon_id:
r += ['--default-admin-socket',
'/var/run/ceph/' + fsid + '-' + daemon_type + '.' + daemon_id +
'.asok']
r += ['--setuser', 'ceph']
r += ['--setgroup', 'ceph']
return r
@ -337,6 +333,7 @@ def get_config_and_both_keyrings():
def get_container_mounts(fsid, daemon_type, daemon_id):
mounts = {}
if fsid:
mounts['/var/run/ceph/%s' % fsid] = '/var/run/ceph:z'
log_dir = get_log_dir(fsid)
mounts[log_dir] = '/var/log/ceph:z'
mounts['/var/lib/ceph/%s/crash' % fsid] = '/var/lib/ceph/crash:z'
@ -447,9 +444,9 @@ def deploy_daemon(fsid, daemon_type, daemon_id, c, uid, gid,
)
pc.run()
deploy_daemon_units(fsid, daemon_type, daemon_id, c)
deploy_daemon_units(fsid, uid, gid, daemon_type, daemon_id, c)
def deploy_daemon_units(fsid, daemon_type, daemon_id, c,
def deploy_daemon_units(fsid, uid, gid, daemon_type, daemon_id, c,
enable=True, start=True):
# cmd
data_dir = get_data_dir(fsid, daemon_type, daemon_id)
@ -459,7 +456,7 @@ def deploy_daemon_units(fsid, daemon_type, daemon_id, c,
# systemd
install_base_units(fsid)
unit = get_unit_file(fsid)
unit = get_unit_file(fsid, uid, gid)
unit_file = 'ceph-%s@.service' % (fsid)
with open(args.unit_dir + '/' + unit_file + '.new', 'w') as f:
f.write(unit)
@ -587,7 +584,7 @@ def deploy_crash(fsid, uid, gid, config, keyring):
subprocess.check_output(['systemctl', 'enable', unit_name])
subprocess.check_output(['systemctl', 'start', unit_name])
def get_unit_file(fsid):
def get_unit_file(fsid, uid, gid):
u = """[Unit]
Description=Ceph daemon for {fsid}
@ -606,10 +603,9 @@ LimitNOFILE=1048576
LimitNPROC=1048576
EnvironmentFile=-/etc/environment
ExecStartPre=-{podman_path} rm ceph-{fsid}-%i
ExecStartPre=-mkdir -p /var/run/ceph
ExecStartPre=-install -d -m0770 -o {uid} -g {gid} /var/run/ceph/{fsid}
ExecStart={data_dir}/{fsid}/%i/cmd
ExecStop=-{podman_path} stop ceph-{fsid}-%i
ExecStopPost=-/bin/rm -f /var/run/ceph/{fsid}-%i.asok
Restart=on-failure
RestartSec=10s
TimeoutStartSec=120
@ -622,6 +618,8 @@ WantedBy=ceph-{fsid}.target
""".format(
podman_path=podman_path,
fsid=fsid,
uid=uid,
gid=gid,
data_dir=args.data_dir)
return u
@ -856,7 +854,7 @@ def command_bootstrap():
f.write(config)
mon_c = get_container(fsid, 'mon', mon_id)
deploy_daemon_units(fsid, 'mon', mon_id, mon_c)
deploy_daemon_units(fsid, uid, gid, 'mon', mon_id, mon_c)
logger.info('Waiting for mon to start...')
while True:
@ -1288,7 +1286,7 @@ def command_adopt():
logger.info('Creating new units...')
c = get_container(fsid, daemon_type, daemon_id)
deploy_daemon_units(fsid, daemon_type, daemon_id, c,
deploy_daemon_units(fsid, uid, gid, daemon_type, daemon_id, c,
enable=True, # unconditionally enable the new unit
start=active)
else: