From 99854fc46595961d3df48f62eb6b863a57bee58e Mon Sep 17 00:00:00 2001 From: xiepaup Date: Fri, 15 Dec 2023 15:08:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(redis):=20=E4=B8=BB=E4=BB=8E=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E9=87=8D=E6=96=B0=E4=B8=8B=E5=8F=91=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=20=20#2623?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scene/redis/redis_cluster_scene_mss.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_scene_mss.py b/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_scene_mss.py index c90d75721a..0456525fb4 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_scene_mss.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_scene_mss.py @@ -30,6 +30,7 @@ RedisActPayload, ) from backend.flow.plugins.components.collections.redis.redis_db_meta import RedisDBMetaComponent +from backend.flow.plugins.components.collections.redis.trans_flies import TransFileComponent from backend.flow.utils.redis.redis_context_dataclass import ActKwargs, CommonContext from backend.flow.utils.redis.redis_db_meta import RedisDBMeta from backend.flow.utils.redis.redis_proxy_util import get_cache_backup_mode, get_twemproxy_cluster_server_shards @@ -166,14 +167,11 @@ def generate_ms_switch_flow(self, flow_data, act_kwargs, ms_switch, force=False) 4. 刷新 new master 监控 5. 元数据修改 old-master 2 unavliable. """ - # "pairs": [ - # {"redis_master": "1.1.2.3", "redis_slave": "1.1.2.4"} - # ] redis_pipeline = SubBuilder(root_id=self.root_id, data=flow_data) twemproxy_server_shards = get_twemproxy_cluster_server_shards( act_kwargs.cluster["bk_biz_id"], act_kwargs.cluster["cluster_id"], act_kwargs.cluster["slave_ins_map"] ) - # 执行切换 ##################################################################################### + sync_relations, master_ips, slave_ips = [], [], [] for ms_pair in ms_switch["pairs"]: master_ip = ms_pair.get("redis_master", "why.no.ip.input") @@ -200,6 +198,19 @@ def generate_ms_switch_flow(self, flow_data, act_kwargs, ms_switch, force=False) } ) sync_relations.append(sync_params) + + # 重新下发介质 ################################################################################### + trans_files = GetFileList(db_type=DBType.Redis) + act_kwargs.file_list = trans_files.redis_cluster_apply_proxy(act_kwargs.cluster["cluster_type"]) + act_kwargs.exec_ip = master_ips + slave_ips + redis_pipeline.add_act( + act_name=_("{}-下发介质包").format(master_ips + slave_ips), + act_component_code=TransFileComponent.code, + kwargs=asdict(act_kwargs), + ) + # 重新下发介质 ################################################################################### + + # 执行切换 ##################################################################################### act_kwargs.cluster["switch_condition"] = { "sync_type": SyncType.SYNC_MS.value, "is_check_sync": force, # 强制切换