|
@@ -257,6 +257,7 @@ def release_instances(ecs_client, instance_ids, force=False):
|
|
|
else:
|
|
|
logging.error(f"Release instances fail!!!")
|
|
|
sys.exit()
|
|
|
+ time.sleep(3)
|
|
|
|
|
|
|
|
|
def get_instances_status(ecs_client, instance_ids):
|
|
@@ -286,6 +287,7 @@ def get_instances_status(ecs_client, instance_ids):
|
|
|
else:
|
|
|
logging.error(response)
|
|
|
sys.exit()
|
|
|
+ time.sleep(3)
|
|
|
|
|
|
|
|
|
def stop_instances(ecs_client, instance_ids, force_stop=False):
|
|
@@ -308,6 +310,7 @@ def stop_instances(ecs_client, instance_ids, force_stop=False):
|
|
|
else:
|
|
|
logging.error(f"Failed to stop instances: {response}")
|
|
|
sys.exit()
|
|
|
+ time.sleep(3)
|
|
|
|
|
|
|
|
|
def send_request(ecs_client, request):
|
|
@@ -392,7 +395,7 @@ def add_servers_to_server_group(alb_client, server_group_ids, instance_ids, weig
|
|
|
:param weight: 权重
|
|
|
:param port: 后端服务器使用的端口
|
|
|
"""
|
|
|
- instance_ids_array = [instance_ids[i:i + 100] for i in range(0, len(instance_ids), 100)]
|
|
|
+ instance_ids_array = [instance_ids[i:i + 200] for i in range(0, len(instance_ids), 200)]
|
|
|
for instance_ids_sub_array in instance_ids_array:
|
|
|
servers = []
|
|
|
for i in range(len(instance_ids_sub_array)):
|
|
@@ -422,9 +425,9 @@ def add_servers_to_server_group(alb_client, server_group_ids, instance_ids, weig
|
|
|
try:
|
|
|
alb_client.add_servers_to_server_group_with_options(request, runtime)
|
|
|
logging.info(
|
|
|
- f"Successfully added instance_ids_sub_array {instance_ids_sub_array} to server group {server_group_id} with weight {weight}.")
|
|
|
+ f"Successfully added count:{len(instance_ids_sub_array)} instance_ids: {instance_ids_sub_array} to server group {server_group_id} with weight {weight}.")
|
|
|
except Exception as e:
|
|
|
- logging.error(f"Failed to add instance_ids_sub_array {instance_ids_sub_array} to server group {server_group_id}: {str(e)}")
|
|
|
+ logging.error(f"Failed to add count:{len(instance_ids_sub_array)} instance_ids: {instance_ids_sub_array} to server group {server_group_id}: {str(e)}")
|
|
|
sys.exit()
|
|
|
time.sleep(10)
|
|
|
|
|
@@ -436,7 +439,7 @@ def remove_servers_from_server_group(alb_client, server_group_id_list, instance_
|
|
|
:param instance_ids: 实例ID list
|
|
|
:param port: 后端服务器使用的端口
|
|
|
"""
|
|
|
- instance_ids_array = [instance_ids[i:i + 100] for i in range(0, len(instance_ids), 100)]
|
|
|
+ instance_ids_array = [instance_ids[i:i + 200] for i in range(0, len(instance_ids), 200)]
|
|
|
for instance_ids_sub_array in instance_ids_array:
|
|
|
servers = []
|
|
|
for instance_id in instance_ids_sub_array:
|
|
@@ -457,9 +460,9 @@ def remove_servers_from_server_group(alb_client, server_group_id_list, instance_
|
|
|
)
|
|
|
try:
|
|
|
alb_client.remove_servers_from_server_group_with_options(request, runtime)
|
|
|
- logging.info(f"Successfully removed instance_ids_sub_array {instance_ids_sub_array} from server group {server_group_id}.")
|
|
|
+ logging.info(f"Successfully removed count: {len(instance_ids_sub_array)} instance_ids: {instance_ids_sub_array} from server group {server_group_id}.")
|
|
|
except Exception as e:
|
|
|
- logging.error(f"Failed to remove instance_ids_sub_array {instance_ids_sub_array} from server group {server_group_id}: {str(e)}")
|
|
|
+ logging.error(f"Failed to remove count: {len(instance_ids_sub_array)} instance_ids: {instance_ids_sub_array} from server group {server_group_id}: {str(e)}")
|
|
|
sys.exit()
|
|
|
time.sleep(10)
|
|
|
|
|
@@ -532,7 +535,7 @@ def update_server_group_server_weight(alb_client, server_group_id_list, instance
|
|
|
# logging.info(f"instance_id_list = {instance_id_list} request = {request}")
|
|
|
alb_client.update_server_group_servers_attribute_with_options(request, runtime)
|
|
|
logging.info(
|
|
|
- f"Successfully updated instance_ids_sub_array {instance_ids_sub_array} in group {server_group_id} to weight {weight}.")
|
|
|
+ f"Successfully updated count = {len(instance_ids_sub_array)} instance_ids: {instance_ids_sub_array} in group {server_group_id} to weight {weight}.")
|
|
|
except Exception as e:
|
|
|
logging.error(e)
|
|
|
sys.exit()
|