]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: using short hostname to create the initial mon and mgr 49866/head
authorRedouane Kachach <rkachach@redhat.com>
Wed, 25 Jan 2023 09:14:59 +0000 (10:14 +0100)
committerRedouane Kachach <rkachach@redhat.com>
Thu, 26 Jan 2023 15:50:58 +0000 (16:50 +0100)
Fixes: https://tracker.ceph.com/issues/58466
Signed-off-by: Redouane Kachach <rkachach@redhat.com>
src/cephadm/cephadm.py

index 07dcecd06524513e1183bb6e3b097ae56f8377f1..3180ab71c70770042f0105c361e53f8d29d825db 100755 (executable)
@@ -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)