diff --git a/launch/src/opendev_launch/launch_node.py b/launch/src/opendev_launch/launch_node.py index 937db1a2f1..eee342b9ef 100755 --- a/launch/src/opendev_launch/launch_node.py +++ b/launch/src/opendev_launch/launch_node.py @@ -21,6 +21,7 @@ import argparse import os import shutil +import socket import subprocess import sys import threading @@ -228,6 +229,19 @@ def bootstrap_server(server, key, name, volume_device, keep, else: raise + timeout = 120 + start = time.perf_counter() + while True: + try: + print("Waiting for ssh...") + with socket.create_connection((host_ip, 22), timeout=5): + break + except OSError as e: + if time.perf_counter() - start >= timeout: + raise Exception("Host did not reboot within timeout") + time.sleep(10) + print("Host rebooted!") + def build_server(cloud, name, image, flavor, volume, keep, network, boot_from_volume, config_drive,