Browse Source

optimize sleep time

supeng 4 months ago
parent
commit
c88feb6c12

+ 2 - 2
gateway/gateway_update.py

@@ -65,8 +65,8 @@ def update(instance_id, port):
         print("开始健康检查")
         checkHealth(ipadd)
         print("%s :权重修改中......" % (ipadd))
-        # weight_list = [(10, 5), (20, 5), (40, 5), (60, 5), (80, 5), (100, 5)]
-        weight_list = [(10, 10), (20, 10), (40, 10), (60, 10), (80, 10), (100, 10)]
+        weight_list = [(10, 5), (20, 5), (40, 5), (60, 5), (80, 5), (100, 5)]
+        # weight_list = [(10, 10), (20, 10), (40, 10), (60, 10), (80, 10), (100, 10)]
         utils.update_server_group_servers_attribute(alb_client, gateway_config.server_group_id_list, instance_id_list=[instance_id], weight_list=weight_list, port=port)
         success_count += 1
         print("更新进度" + "%s/%s" % (success_count, total))

+ 2 - 2
longvideoapi/longvideoapi_grayscale_update.py

@@ -141,8 +141,8 @@ def update_instance(ecs_client, alb_client, instance_id, version, port):
     # 机器探活成功
     time.sleep(20)
     health_instance_ids = [instance_id for instance_id, _ in health_instances]
-    # add_weight_list = [(10, 5), (20, 5), (40, 5), (60, 5), (80, 5), (100, 5)]
-    add_weight_list = [(10, 10), (20, 10), (40, 10), (60, 10), (80, 10), (100, 10)]
+    add_weight_list = [(10, 5), (20, 5), (40, 5), (60, 5), (80, 5), (100, 5)]
+    # add_weight_list = [(10, 10), (20, 10), (40, 10), (60, 10), (80, 10), (100, 10)]
     utils.update_server_group_servers_attribute(alb_client=alb_client,
                                                 server_group_id_list=longvideoapi_config.server_group_id_list,
                                                 instance_id_list=health_instance_ids,

+ 2 - 2
longvideoapi/longvideoapi_restart.py

@@ -36,8 +36,8 @@ def server_restart(alb_client, ecs_client, instance_id, image_name, port):
         logging.info("Health check finished.")
 
         # 设置权重
-        # add_weight_list = [(10, 5), (20, 5), (40, 5), (60, 5), (80, 5), (100, 5)]
-        add_weight_list = [(10, 10), (20, 10), (40, 10), (60, 10), (80, 10), (100, 10)]
+        add_weight_list = [(10, 5), (20, 5), (40, 5), (60, 5), (80, 5), (100, 5)]
+        # add_weight_list = [(10, 10), (20, 10), (40, 10), (60, 10), (80, 10), (100, 10)]
         utils.update_server_group_servers_attribute(alb_client=alb_client,
                                                     server_group_id_list=longvideoapi_config.server_group_id_list,
                                                     instance_id_list=[instance_id],

+ 4 - 4
longvideoapi/longvideoapi_update_k.py

@@ -90,8 +90,8 @@ async def ess_instance(ecs_client, alb_client, ess_count, max_workers, version,
 
         time.sleep(20)
         logging.info(f"start update weight count: {len(health_instance_ids)} instances: {health_instance_ids} server groups: {longvideoapi_config.server_group_id_list}.")
-        # add_weight_list = [(10, 5), (20, 5), (40, 5), (60, 5), (80, 5), (100, 5)]
-        add_weight_list = [(10, 10), (20, 10), (40, 10), (60, 10), (80, 10), (100, 10)]
+        add_weight_list = [(10, 5), (20, 5), (40, 5), (60, 5), (80, 5), (100, 5)]
+        # add_weight_list = [(10, 10), (20, 10), (40, 10), (60, 10), (80, 10), (100, 10)]
         utils.update_server_group_servers_attribute(alb_client,
                                                     server_group_id_list=longvideoapi_config.server_group_id_list,
                                                     instance_id_list=health_instance_ids,
@@ -226,8 +226,8 @@ async def update_instance(ecs_client, alb_client, instance_ids, max_workers, ver
             time.sleep(10)
             health_instance_ids = [instance_id for instance_id, _ in health_instances]
 
-            # add_weight_list = [(10, 5), (20, 5), (40, 5), (60, 5), (80, 5), (100, 5)]
-            add_weight_list = [(10, 10), (20, 10), (40, 10), (60, 10), (80, 10), (100, 10)]
+            add_weight_list = [(10, 5), (20, 5), (40, 5), (60, 5), (80, 5), (100, 5)]
+            # add_weight_list = [(10, 10), (20, 10), (40, 10), (60, 10), (80, 10), (100, 10)]
             utils.update_server_group_servers_attribute(alb_client,
                                                         server_group_id_list=longvideoapi_config.server_group_id_list,
                                                         instance_id_list=health_instance_ids,

+ 3 - 3
longvideoapi/utils.py

@@ -432,7 +432,7 @@ def add_servers_to_server_group(alb_client, server_group_ids, instance_ids, weig
             except Exception as 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)
+        time.sleep(5)
 
 def remove_servers_from_server_group(alb_client, server_group_id_list, instance_ids, port):
     """
@@ -467,7 +467,7 @@ def remove_servers_from_server_group(alb_client, server_group_id_list, instance_
             except Exception as 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)
+        time.sleep(5)
 
 
 def list_server_group_servers(alb_client, server_group_id):
@@ -541,7 +541,7 @@ def update_server_group_server_weight(alb_client, server_group_id_list, instance
             except Exception as e:
                 logging.error(e)
                 sys.exit()
-        time.sleep(10)
+        time.sleep(5)
 
 
 def update_server_group_servers_attribute(alb_client, server_group_id_list, instance_id_list, weight_list, port):