mirror of
https://github.com/ceph/ceph
synced 2025-01-11 21:50:26 +00:00
cephadm: validate --fsid
during bootstrap
Signed-off-by: Michael Fritch <mfritch@suse.com>
This commit is contained in:
parent
64281bb394
commit
37ff72ac9b
@ -4026,12 +4026,15 @@ def command_bootstrap(ctx):
|
||||
|
||||
# initial vars
|
||||
fsid = ctx.fsid or make_fsid()
|
||||
if not is_fsid(fsid):
|
||||
raise Error('not an fsid: %s' % fsid)
|
||||
logger.info('Cluster fsid: %s' % fsid)
|
||||
|
||||
hostname = get_hostname()
|
||||
if '.' in hostname and not ctx.allow_fqdn_hostname:
|
||||
raise Error('hostname is a fully qualified domain name (%s); either fix (e.g., "sudo hostname %s" or similar) or pass --allow-fqdn-hostname' % (hostname, hostname.split('.')[0]))
|
||||
mon_id = ctx.mon_id or hostname
|
||||
mgr_id = ctx.mgr_id or generate_service_id()
|
||||
logger.info('Cluster fsid: %s' % fsid)
|
||||
|
||||
lock = FileLock(ctx, fsid)
|
||||
lock.acquire()
|
||||
|
@ -1157,3 +1157,24 @@ class TestBootstrap(TestCephAdm):
|
||||
with with_cephadm_ctx(cmd, hostname=hostname) as ctx:
|
||||
retval = cd.command_bootstrap(ctx)
|
||||
assert retval == 0
|
||||
|
||||
@pytest.mark.parametrize('fsid, err',
|
||||
[
|
||||
('', None),
|
||||
('00000000-0000-0000-0000-0000deadbeef', None),
|
||||
('00000000-0000-0000-0000-0000deadbeez', 'not an fsid'),
|
||||
])
|
||||
def test_fsid(self, fsid, err, cephadm_fs):
|
||||
cmd = self._get_cmd(
|
||||
'--mon-ip', '192.168.1.1',
|
||||
'--skip-mon-network',
|
||||
'--fsid', fsid,
|
||||
)
|
||||
|
||||
with with_cephadm_ctx(cmd) as ctx:
|
||||
if err:
|
||||
with pytest.raises(cd.Error, match=err):
|
||||
cd.command_bootstrap(ctx)
|
||||
else:
|
||||
retval = cd.command_bootstrap(ctx)
|
||||
assert retval == 0
|
||||
|
Loading…
Reference in New Issue
Block a user