Skip to content

Commit 4b0dd66

Browse files
committed
Fix: bootstrap: Detect cluster service on init node before saving the canonical hostname (bsc#1222714)
1 parent 7fed1b8 commit 4b0dd66

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

crmsh/bootstrap.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,7 @@ def join_ssh_impl(local_user, seed_host, seed_user, ssh_public_keys: typing.List
16251625
user_by_host.add(local_user, utils.this_node())
16261626
user_by_host.set_no_generating_ssh_key(bool(ssh_public_keys))
16271627
user_by_host.save_local()
1628+
detect_cluster_service_on_node(seed_host)
16281629
user_by_host.add(seed_user, get_node_canonical_hostname(seed_host))
16291630
user_by_host.save_local()
16301631

@@ -2204,6 +2205,17 @@ def bootstrap_add(context):
22042205
print(out)
22052206

22062207

2208+
def detect_cluster_service_on_node(peer_node):
2209+
service_manager = ServiceManager()
2210+
for _ in range(REJOIN_COUNT):
2211+
if service_manager.service_is_active("pacemaker.service", peer_node):
2212+
break
2213+
logger.warning("Cluster is inactive on %s. Retry in %d seconds", peer_node, REJOIN_INTERVAL)
2214+
sleep(REJOIN_INTERVAL)
2215+
else:
2216+
utils.fatal("Cluster is inactive on {}".format(peer_node))
2217+
2218+
22072219
def bootstrap_join(context):
22082220
"""
22092221
Join cluster process
@@ -2242,24 +2254,13 @@ def bootstrap_join(context):
22422254
init_upgradeutil()
22432255
remote_user, cluster_node = _parse_user_at_host(_context.cluster_node, _context.current_user)
22442256
utils.ping_node(cluster_node)
2245-
22462257
join_ssh(cluster_node, remote_user)
22472258
remote_user = utils.user_of(cluster_node)
22482259

2249-
service_manager = ServiceManager()
2250-
n = 0
2251-
while n < REJOIN_COUNT:
2252-
if service_manager.service_is_active("pacemaker.service", cluster_node):
2253-
break
2254-
n += 1
2255-
logger.warning("Cluster is inactive on %s. Retry in %d seconds", cluster_node, REJOIN_INTERVAL)
2256-
sleep(REJOIN_INTERVAL)
2257-
else:
2258-
utils.fatal("Cluster is inactive on {}".format(cluster_node))
2259-
22602260
lock_inst = lock.RemoteLock(cluster_node)
22612261
try:
22622262
with lock_inst.lock():
2263+
service_manager = ServiceManager()
22632264
_context.node_list_in_cluster = utils.fetch_cluster_node_list_from_node(cluster_node)
22642265
setup_passwordless_with_other_nodes(cluster_node, remote_user)
22652266
join_remote_auth(cluster_node, remote_user)

0 commit comments

Comments
 (0)