Skip to content

Commit 1924efd

Browse files
authored
Merge pull request ceph#57037 from adk3798/cephadm-limit-shell-mounts
cephadm: limit mounts for shell and ceph-volume commands
2 parents e656af9 + 8164efe commit 1924efd

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

qa/tasks/cephadm.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,8 +1086,18 @@ def ceph_osds(ctx, config):
10861086
short_dev = dev
10871087
log.info('Deploying %s on %s with %s...' % (
10881088
osd, remote.shortname, dev))
1089-
_shell(ctx, cluster_name, remote, [
1090-
'ceph-volume', 'lvm', 'zap', dev])
1089+
remote.run(
1090+
args=[
1091+
'sudo',
1092+
ctx.cephadm,
1093+
'--image', ctx.ceph[cluster_name].image,
1094+
'ceph-volume',
1095+
'-c', '/etc/ceph/{}.conf'.format(cluster_name),
1096+
'-k', '/etc/ceph/{}.client.admin.keyring'.format(cluster_name),
1097+
'--fsid', ctx.ceph[cluster_name].fsid,
1098+
'--', 'lvm', 'zap', dev
1099+
]
1100+
)
10911101
add_osd_args = ['ceph', 'orch', 'daemon', 'add', 'osd',
10921102
remote.shortname + ':' + short_dev]
10931103
osd_method = config.get('osd_method')

src/cephadm/cephadm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3172,7 +3172,7 @@ def command_shell(ctx):
31723172
daemon_type = ctx.name
31733173
daemon_id = None
31743174
else:
3175-
daemon_type = 'osd' # get the most mounts
3175+
daemon_type = 'shell' # get limited set of mounts
31763176
daemon_id = None
31773177

31783178
if ctx.fsid and daemon_type in ceph_daemons():
@@ -3310,7 +3310,7 @@ def command_ceph_volume(ctx):
33103310
lock.acquire()
33113311

33123312
(uid, gid) = (0, 0) # ceph-volume runs as root
3313-
mounts = get_container_mounts_for_type(ctx, ctx.fsid, 'osd')
3313+
mounts = get_container_mounts_for_type(ctx, ctx.fsid, 'ceph-volume')
33143314

33153315
tmp_config = None
33163316
tmp_keyring = None

src/cephadm/cephadmlib/daemons/ceph.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,17 @@ def get_ceph_mounts_for_type(
424424
"""
425425
mounts = dict()
426426

427-
if daemon_type in ceph_daemons():
427+
if daemon_type in ceph_daemons() or daemon_type in [
428+
'ceph-volume',
429+
'shell',
430+
]:
428431
if fsid:
429432
run_path = os.path.join('/var/run/ceph', fsid)
430433
if os.path.exists(run_path):
431434
mounts[run_path] = '/var/run/ceph:z'
432435
log_dir = os.path.join(ctx.log_dir, fsid)
436+
if not os.path.exists(log_dir):
437+
os.mkdir(log_dir)
433438
mounts[log_dir] = '/var/log/ceph:z'
434439
crash_dir = '/var/lib/ceph/%s/crash' % fsid
435440
if os.path.exists(crash_dir):
@@ -438,14 +443,19 @@ def get_ceph_mounts_for_type(
438443
journald_sock_dir = '/run/systemd/journal'
439444
mounts[journald_sock_dir] = journald_sock_dir
440445

441-
if daemon_type in ['mon', 'osd', 'clusterless-ceph-volume']:
446+
if daemon_type in [
447+
'mon',
448+
'osd',
449+
'ceph-volume',
450+
'clusterless-ceph-volume',
451+
]:
442452
mounts['/dev'] = '/dev' # FIXME: narrow this down?
443453
mounts['/run/udev'] = '/run/udev'
444-
if daemon_type in ['osd', 'clusterless-ceph-volume']:
454+
if daemon_type in ['osd', 'ceph-volume', 'clusterless-ceph-volume']:
445455
mounts['/sys'] = '/sys' # for numa.cc, pick_address, cgroups, ...
446456
mounts['/run/lvm'] = '/run/lvm'
447457
mounts['/run/lock/lvm'] = '/run/lock/lvm'
448-
if daemon_type == 'osd':
458+
if daemon_type in ['osd', 'ceph-volume']:
449459
# selinux-policy in the container may not match the host.
450460
if HostFacts(ctx).selinux_enabled:
451461
cluster_dir = f'{ctx.data_dir}/{fsid}'
@@ -458,7 +468,10 @@ def get_ceph_mounts_for_type(
458468
logger.error(
459469
f'Cluster direcotry {cluster_dir} does not exist.'
460470
)
471+
if daemon_type == 'osd':
461472
mounts['/'] = '/rootfs'
473+
elif daemon_type == 'ceph-volume':
474+
mounts['/'] = '/rootfs:rslave'
462475

463476
try:
464477
if (

src/cephadm/tests/test_cephadm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ def test_mon_crush_location(self, funkypatch):
380380
_deploy_daemon = funkypatch.patch('cephadm.deploy_daemon')
381381
funkypatch.patch('cephadm.make_var_run')
382382
funkypatch.patch('cephadmlib.file_utils.make_run_dir')
383+
funkypatch.patch('os.mkdir')
383384
_migrate_sysctl = funkypatch.patch('cephadm.migrate_sysctl_dir')
384385
funkypatch.patch(
385386
'cephadm.check_unit',

0 commit comments

Comments
 (0)