# type: (str, str, Union[int, str]) -> List[str]
r = list() # type: List[str]
- if daemon_type in Ceph.daemons:
+ if daemon_type in Ceph.daemons and daemon_type != 'crash':
r += [
'--setuser', 'ceph',
'--setgroup', 'ceph',
cdata_dir = '/var/lib/ceph/radosgw/ceph-rgw.%s' % (daemon_id)
else:
cdata_dir = '/var/lib/ceph/%s/ceph-%s' % (daemon_type, daemon_id)
- mounts[data_dir] = cdata_dir + ':z'
+ if daemon_type != 'crash':
+ mounts[data_dir] = cdata_dir + ':z'
if not no_config:
mounts[data_dir + '/config'] = '/etc/ceph/ceph.conf:z'
- if daemon_type == 'rbd-mirror':
- # rbd-mirror does not search for its keyring in a data directory
- mounts[data_dir + '/keyring'] = '/etc/ceph/ceph.client.rbd-mirror.%s.keyring' % daemon_id
+ if daemon_type == 'rbd-mirror' or daemon_type == 'crash':
+ # these do not search for their keyrings in a data directory
+ mounts[data_dir + '/keyring'] = '/etc/ceph/ceph.client.%s.%s.keyring' % (daemon_type, daemon_id)
if daemon_type in ['mon', 'osd']:
mounts['/dev'] = '/dev' # FIXME: narrow this down?
elif daemon_type == 'rbd-mirror':
entrypoint = '/usr/bin/rbd-mirror'
name = 'client.rbd-mirror.%s' % daemon_id
+ elif daemon_type == 'crash':
+ entrypoint = '/usr/bin/ceph-crash'
+ name = 'client.crash.%s' % daemon_id
elif daemon_type in ['mon', 'mgr', 'mds', 'osd']:
entrypoint = '/usr/bin/ceph-' + daemon_type
name = '%s.%s' % (daemon_type, daemon_id)
entrypoint = ''
name = ''
- ceph_args = ['-n', name, '-f']
-
if daemon_type in Monitoring.components:
ceph_args = []
+ elif daemon_type == 'crash':
+ ceph_args = ['-n', name]
+ else:
+ ceph_args = ['-n', name, '-f']
+
return CephContainer(
image=args.image,
# type: (str, int, int, str, str) -> None
crash_dir = os.path.join(args.data_dir, fsid, 'crash')
makedirs(crash_dir, uid, gid, DATA_DIR_MODE)
-
- with open(os.path.join(crash_dir, 'keyring'), 'w') as f:
- os.fchmod(f.fileno(), 0o600)
- os.fchown(f.fileno(), uid, gid)
- f.write(keyring)
- with open(os.path.join(crash_dir, 'config'), 'w') as f:
- os.fchmod(f.fileno(), 0o600)
- os.fchown(f.fileno(), uid, gid)
- f.write(config)
-
- # ceph-crash unit
- mounts = {
- crash_dir: '/var/lib/ceph/crash:z',
- os.path.join(crash_dir, 'config'): '/etc/ceph/ceph.conf:z',
- os.path.join(crash_dir, 'keyring'): '/etc/ceph/ceph.keyring:z',
- }
- c = CephContainer(
- image=args.image,
- entrypoint='/usr/bin/ceph-crash',
- args=['-n', 'client.crash.%s' % get_hostname()],
- volume_mounts=mounts,
- cname='ceph-%s-crash' % (fsid),
- )
- unit_name = 'ceph-%s-crash.service' % fsid
- with open(os.path.join(args.unit_dir, unit_name + '.new'), 'w') as f:
- f.write("""# generated by cephadm
-[Unit]
-Description=Ceph crash collector for {fsid}
-PartOf=ceph-{fsid}.target
-Before=ceph-{fsid}.target
-
-[Service]
-Type=simple
-ExecStartPre=-{container_path} rm ceph-{fsid}-crash
-ExecStart={cmd}
-ExecStop=-{container_path} stop ceph-{fsid}-crash
-KillMode=none
-Restart=always
-RestartSec=10
-StartLimitInterval=10min
-StartLimitBurst=10
-
-[Install]
-WantedBy=ceph-{fsid}.target
-""".format(
- container_path=container_path,
- fsid=fsid,
- cmd=' '.join(c.run_cmd()))
- )
- os.rename(os.path.join(args.unit_dir, unit_name + '.new'),
- os.path.join(args.unit_dir, unit_name))
- subprocess.check_output(['systemctl', 'enable', unit_name])
- subprocess.check_output(['systemctl', 'start', unit_name])
+ c = get_container(args.fsid, 'crash', get_hostname())
+ deploy_daemon(args.fsid, 'crash', get_hostname(), c, uid, gid,
+ config, keyring)
def get_unit_file(fsid, uid, gid):
# type: (str, int, int) -> str
elif is_fsid(i):
fsid = i
for j in os.listdir(os.path.join(data_dir, i)):
- if j == 'crash':
- name = 'crash'
- unit_name = 'ceph-%s-crash.service' % fsid
- elif '.' in j:
+ if '.' in j:
name = j
(daemon_type, daemon_id) = j.split('.', 1)
unit_name = get_unit_name(fsid,
verbose_on_failure=False)
# cluster units
- for unit_name in ['ceph-%s.target' % args.fsid,
- 'ceph-%s-crash.service' % args.fsid]:
+ for unit_name in ['ceph-%s.target' % args.fsid]:
call(['systemctl', 'stop', unit_name],
verbose_on_failure=False)
call(['systemctl', 'reset-failed', unit_name],
# rm units
call_throws(['rm', '-f', args.unit_dir +
'/ceph-%s@.service' % args.fsid])
- call_throws(['rm', '-f', args.unit_dir +
- '/ceph-%s-crash.service' % args.fsid])
call_throws(['rm', '-f', args.unit_dir +
'/ceph-%s.target' % args.fsid])
call_throws(['rm', '-rf',