fix logging messages

pull/37/head
Minh Doan 6 years ago
parent 8662f6dabf
commit 8d3fb33eb0
  1. 24
      aws-experiment-launch/deploy.py

@ -42,15 +42,15 @@ def run_one_region_codedeploy(region_number, region_config, node_name_tag, commi
LOGGER.info("Number of instances: %d" % len(instance_ids)) LOGGER.info("Number of instances: %d" % len(instance_ids))
LOGGER.info("Waiting for all %d instances in region %s to be in RUNNING" % (len(instance_ids), region_number)) LOGGER.info("Waiting for %d instances in region %s to be in RUNNING" % (len(instance_ids), region_number))
waiter = ec2_client.get_waiter('instance_running') waiter = ec2_client.get_waiter('instance_running')
waiter.wait(InstanceIds=instance_ids) waiter.wait(InstanceIds=instance_ids)
print("Waiting for all %d instances in region %s with status OK"% (len(instance_ids), region_number)) print("Waiting for %d instances in region %s with status OK"% (len(instance_ids), region_number))
waiter = ec2_client.get_waiter('instance_status_ok') waiter = ec2_client.get_waiter('instance_status_ok')
waiter.wait(InstanceIds=instance_ids) waiter.wait(InstanceIds=instance_ids)
print("Waiting for all %d instances in region %s with system in OK"% (len(instance_ids), region_number)) print("Waiting for %d instances in region %s with system in OK"% (len(instance_ids), region_number))
waiter = ec2_client.get_waiter('system_status_ok') waiter = ec2_client.get_waiter('system_status_ok')
waiter.wait(InstanceIds=instance_ids) waiter.wait(InstanceIds=instance_ids)
@ -67,8 +67,8 @@ def run_one_region_codedeploy(region_number, region_config, node_name_tag, commi
LOGGER.info("Created deployment group with id %s" % deployment_group_id) LOGGER.info("Created deployment group with id %s" % deployment_group_id)
else: else:
LOGGER.info("Created deployment group with name %s was created" % deployment_group_name) LOGGER.info("Created deployment group with name %s was created" % deployment_group_name)
deployment_id = deploy(codedeploy, application_name, deployment_group_name, repo, commit_id) deployment_id, status = deploy(codedeploy, application_name, deployment_group_name, repo, commit_id)
return region_number, deployment_id return region_number, deployment_id, status
def deploy(codedeploy, application_name, deployment_group, repo, commit_id): def deploy(codedeploy, application_name, deployment_group, repo, commit_id):
@ -94,26 +94,28 @@ def deploy(codedeploy, application_name, deployment_group, repo, commit_id):
} }
) )
if response: if response:
LOGGER.info("Deployment returned with deployment id: " + res["deploymentId"]) LOGGER.info("Deployment returned with deployment id: " + response["deploymentId"])
deployment_id = response["deploymentId"]
else: else:
LOGGER.error("Deployment failed.") LOGGER.error("Deployment failed.")
return None, None
start_time = time.time() start_time = time.time()
status = None status = None
while time.time() - start_time < 600: while time.time() - start_time < 600:
response = codedeploy.get_deployment(deploymentId=deployment_id) response = codedeploy.get_deployment(deploymentId=deployment_id)
if response and response.get('deploymentInfo'): if response and response.get('deploymentInfo'):
status = response.get['deploymentInfo']['status'] status = response['deploymentInfo']['status']
if status in ('Succeeded', 'Failed', 'Stopped'): if status in ('Succeeded', 'Failed', 'Stopped'):
break break
if status: if status:
LOGGER.info("Deployment status " + status) LOGGER.info("Deployment status " + status)
else: else:
LOGGER.info("Deployment status: time out") LOGGER.info("Deployment status: time out")
return deployment_id return deployment_id, status
def run_one_region_codedeploy_wrapper(region_number, region_config, node_name_tag, commit_id): def run_one_region_codedeploy_wrapper(region_number, region_config, node_name_tag, commit_id):
region_number, deployment_id = run_one_region_codedeploy(region_number, region_config, node_name_tag, commit_id) region_number, deployment_id, status = run_one_region_codedeploy(region_number, region_config, node_name_tag, commit_id)
LOGGER.info("deployment of region %s finished with deployment id %s" % (region_number, deployment_id)) LOGGER.info("deployment of region %s finished with deployment id %s with status %s" % (region_number, deployment_id, status))
def launch_code_deploy(region_list, region_config, commit_id): def launch_code_deploy(region_list, region_config, commit_id):
thread_pool = [] thread_pool = []
@ -126,7 +128,7 @@ def launch_code_deploy(region_list, region_config, commit_id):
thread_pool.append(t) thread_pool.append(t)
for t in thread_pool: for t in thread_pool:
t.join() t.join()
LOGGER.info("Done deploying all regions") LOGGER.info("Finished.")
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(

Loading…
Cancel
Save