Browse Source

add print

xuekailun 4 months ago
parent
commit
36e3819d27
2 changed files with 7 additions and 8 deletions
  1. 4 6
      longvideoapi/longvideoapi_grayscale_update.py
  2. 3 2
      longvideoapi/utils.py

+ 4 - 6
longvideoapi/longvideoapi_grayscale_update.py

@@ -89,12 +89,11 @@ def remove_container_image(ecs_client, instance_id, container_name_list):
         except Exception as e:
             j += 1
 
-def update_instance(ecs_client, alb_client, server_group_id_list, instance_id, version, port):
+def update_instance(ecs_client, alb_client, instance_id, version, port):
     """
     线上机器更新
     :param ecs_client:
     :param alb_client: alb客户端连接
-    :param server_group_id_list 后端服务器组
     :param instance_id: instanceId
     :param version: 版本标记
     :param port: 后端服务器使用的端口
@@ -102,10 +101,9 @@ def update_instance(ecs_client, alb_client, server_group_id_list, instance_id, v
     """
     logging.info(f"update instance: {instance_id}")
     # 1. 摘流量,将权重降为0
-    # weight_list = [(0, 20)]  # 设置权重为0,等待20秒
-
+    print(instance_id)
     utils.update_server_group_servers_attribute(alb_client=alb_client,
-                                                server_group_id_list=[server_group_id_list],
+                                                server_group_id_list=longvideoapi_config.server_group_id_list,
                                                 instance_id_list=[instance_id],
                                                 weight_list=[(0, 20)],
                                                 port=port)
@@ -177,7 +175,7 @@ def main():
         # 2. 对其中一台机器进行更新
         instance_id = online_instance_ids[0]
         logging.info(f"update instance start ...")
-        update_instance(ecs_client=ecs_client, alb_client=alb_client, server_group_id_list=longvideoapi_config.server_group_id_list, instance_id=instance_id, version=version, port=longvideoapi_config.port)
+        update_instance(ecs_client=ecs_client, alb_client=alb_client, instance_id=instance_id, version=version, port=longvideoapi_config.port)
         logging.info(f"update instances end!")
 
     except Exception as e:

+ 3 - 2
longvideoapi/utils.py

@@ -475,8 +475,6 @@ def update_server_group_server_weight(alb_client, server_group_id, instance_id,
         alb_client.update_server_group_servers_attribute_with_options(request, runtime)
         print(f"Successfully updated server {instance_id} in group {server_group_id} to weight {weight}.")
     except Exception as e:
-        # print(str(error))
-        # UtilClient.assert_as_string(str(error))
         print(server)
         print(request)
         print('update_server_group_server_weight')
@@ -492,9 +490,11 @@ def update_server_group_servers_attribute(alb_client, server_group_id_list, inst
     :param weight_list: 权重修改列表 type-list [(weight, sleep_time), ...]
     :param port: 后端服务器使用的端口
     """
+    print(instance_id_list)
     for server_group_id in server_group_id_list:
         for instance_id in instance_id_list:
             for weight, sleep_time in weight_list:
+                print(instance_id)
                 update_server_group_server_weight(alb_client, server_group_id, instance_id, weight, port)
                 time.sleep(sleep_time)
 
@@ -535,6 +535,7 @@ async def update_server_group_servers_attribute_async(alb_client, server_group_i
     :param server_group_id_list: 服务器组ID列表
     :param instance_ids: 实例ID列表
     :param weight_list: 权重修改列表 type-list [(weight, sleep_time), ...]
+    :param port: 服务器端口
     """
     tasks = []
     for server_group_id in server_group_id_list: