From 0b807eefb8dbccf1e25c846f8177ddb74c6f333d Mon Sep 17 00:00:00 2001 From: Redouane Kachach Date: Wed, 25 Jan 2023 10:14:59 +0100 Subject: [PATCH] cephadm: using short hostname to create the initial mon and mgr Fixes: https://tracker.ceph.com/issues/58466 Signed-off-by: Redouane Kachach --- src/cephadm/cephadm.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 07dcecd0652..3180ab71c70 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -2031,6 +2031,11 @@ def get_hostname(): return socket.gethostname() +def get_short_hostname(): + # type: () -> str + return get_hostname().split('.', 1)[0] + + def get_fqdn(): # type: () -> str return socket.getfqdn() or socket.gethostname() @@ -2043,8 +2048,8 @@ def get_arch(): def generate_service_id(): # type: () -> str - return get_hostname() + '.' + ''.join(random.choice(string.ascii_lowercase) - for _ in range(6)) + return get_short_hostname() + '.' + ''.join(random.choice(string.ascii_lowercase) + for _ in range(6)) def generate_password(): @@ -5725,7 +5730,7 @@ def command_bootstrap(ctx): 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 + mon_id = ctx.mon_id or get_short_hostname() mgr_id = ctx.mgr_id or generate_service_id() lock = FileLock(ctx, fsid) -- 2.47.3