fix&refactor: improve connection retry logic and remove unnecessary wait time for AWS instance readiness
This commit is contained in:
@@ -51,7 +51,17 @@ class SetupController:
|
||||
"parameters": dick like {str, Any} providing the keyword
|
||||
parameters
|
||||
}
|
||||
"""
|
||||
"""
|
||||
# make sure connection can be established
|
||||
retry = 0
|
||||
while retry < 30:
|
||||
try:
|
||||
_ = requests.get(self.http_server + "/terminal")
|
||||
break
|
||||
except:
|
||||
time.sleep(5)
|
||||
retry += 1
|
||||
logger.info(f"try to connect {self.http_server}, retry {retry}/30")
|
||||
|
||||
for cfg in config:
|
||||
config_type: str = cfg["type"]
|
||||
|
||||
@@ -145,8 +145,7 @@ class AWSProvider(Provider):
|
||||
logger.info(f"New instance {new_instance_id} launched from snapshot {snapshot_name}.")
|
||||
logger.info(f"Waiting for instance {new_instance_id} to be running...")
|
||||
ec2_client.get_waiter('instance_running').wait(InstanceIds=[new_instance_id])
|
||||
# wait 60 seconds for the instance to be ready
|
||||
time.sleep(60)
|
||||
|
||||
logger.info(f"Instance {new_instance_id} is ready.")
|
||||
|
||||
return new_instance_id
|
||||
|
||||
Reference in New Issue
Block a user