@@ -2420,12 +2420,12 @@ def package_is_installed(pkg, remote_addr=None):
24202420 return rc == 0
24212421
24222422
2423- def node_reachable_check (node , ping_count = 1 , port = 22 , timeout = 3 ):
2423+ def node_reachable_check (node , ping_count = 1 , port = 22 , timeout = 3 , only_ping = False ):
24242424 """
24252425 Check if node is reachable by using ping and socket to ssh port
24262426 """
24272427 rc , _ , _ = ShellUtils ().get_stdout_stderr (f"ping -n -c { ping_count } -W { timeout } { node } " )
2428- if rc == 0 :
2428+ if rc == 0 and only_ping :
24292429 return True
24302430 # ping failed, try to connect to ssh port by socket
24312431 if check_port_open (node , port , timeout ):
@@ -2466,6 +2466,12 @@ def __init__(self, msg: str, dead_nodes=None):
24662466 self .dead_nodes = dead_nodes or []
24672467
24682468
2469+ class UnreachableNodeError (ValueError ):
2470+ def __init__ (self , msg : str , unreachable_nodes = None ):
2471+ super ().__init__ (msg )
2472+ self .unreachable_nodes = unreachable_nodes or []
2473+
2474+
24692475def check_all_nodes_reachable (action_to_do : str , peer_node : str = None ):
24702476 """
24712477 Check if all cluster nodes are reachable
@@ -2487,8 +2493,17 @@ def check_all_nodes_reachable(action_to_do: str, peer_node: str = None):
24872493 """
24882494 raise DeadNodeError (msg , dead_nodes )
24892495
2496+ unreachable_nodes = []
24902497 for node in online_nodes :
2491- node_reachable_check (node )
2498+ try :
2499+ node_reachable_check (node )
2500+ except ValueError :
2501+ unreachable_nodes .append (node )
2502+ if unreachable_nodes :
2503+ msg = f"""There are nodes unreachable: { ', ' .join (unreachable_nodes )} .
2504+ Please check the network connectivity before { action_to_do } .
2505+ """
2506+ raise UnreachableNodeError (msg , unreachable_nodes )
24922507
24932508
24942509def re_split_string (reg , string ):
0 commit comments