From aecb764ec32c7864754e096415d4dddd7e3dff95 Mon Sep 17 00:00:00 2001 From: OMG-By <504094596@qq.com> Date: Wed, 29 Nov 2023 11:48:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(redis):=20=E7=9B=91=E5=90=AC=E8=AF=B7?= =?UTF-8?q?=E6=B1=82act=E9=9C=80=E8=A6=81=E8=80=83=E8=99=91=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=20#2178?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pkg/atomjobs/atomproxy/predixy_operate.go | 8 + .../atomjobs/atomproxy/twemproxy_operate.go | 11 ++ .../scene/redis/redis_cluster_apply_flow.py | 4 +- .../scene/redis/redis_cluster_shutdown.py | 3 +- .../flow/utils/redis/redis_act_playload.py | 169 +++++++++--------- 5 files changed, 109 insertions(+), 86 deletions(-) diff --git a/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomproxy/predixy_operate.go b/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomproxy/predixy_operate.go index 07f77392f3..958e963fd0 100644 --- a/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomproxy/predixy_operate.go +++ b/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomproxy/predixy_operate.go @@ -99,6 +99,14 @@ func (job *PredixyOperate) Run() (err error) { } else { // stop or shutdown if !running { + if op == consts.ProxyShutdown { + if err := common.DeleteExporterConfigFile(port); err != nil { + job.runtime.Logger.Warn("predixy %d DeleteExporterConfigFile return err:%v", port, err) + } else { + job.runtime.Logger.Info("predixy %d DeleteExporterConfigFile success", port) + } + return job.DirBackup(execUser, port) + } return nil } cmd = []string{"su", execUser, "-c", fmt.Sprintf("%s %s", stopScript, strconv.Itoa(port))} diff --git a/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomproxy/twemproxy_operate.go b/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomproxy/twemproxy_operate.go index 076e65182c..1581054903 100644 --- a/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomproxy/twemproxy_operate.go +++ b/dbm-services/redis/db-tools/dbactuator/pkg/atomjobs/atomproxy/twemproxy_operate.go @@ -103,6 +103,16 @@ func (job *TwemproxyOperate) Run() (err error) { } else { // stop or shutdown if !running { + // 如果是shutdown,此时需要清理相关目录 + if op == consts.ProxyShutdown { + if err := common.DeleteExporterConfigFile(port); err != nil { + job.runtime.Logger.Warn("twemproxy %d DeleteExporterConfigFile return err:%v", port, err) + } else { + job.runtime.Logger.Info("twemproxy %d DeleteExporterConfigFile success", port) + } + + return job.DirBackup(execUser, port) + } return nil } cmd = []string{"su", execUser, "-c", fmt.Sprintf("%s %s", stopScript, strconv.Itoa(port))} @@ -115,6 +125,7 @@ func (job *TwemproxyOperate) Run() (err error) { } time.Sleep(5 * time.Second) + // 二次检查进程状态 running, err = job.IsTwemproxyRunning(port) job.runtime.Logger.Info("check twemproxy %d after exec cmd. status is %s", port, running) if running && op == consts.ProxyStart { diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_apply_flow.py b/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_apply_flow.py index 0976db9ea5..370bcb8468 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_apply_flow.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_apply_flow.py @@ -281,7 +281,9 @@ def deploy_redis_cluster_flow(self): "domain_name": self.data["domain_name"], } if self.data["cluster_type"] == ClusterType.TendisTwemproxyRedisInstance.value: - act_kwargs.cluster["conf"]["cluster-enabled"] = ClusterStatus.REDIS_CLUSTER_NO + # Redis2版本的配置没有cluster-enabled这个配置项 + if not self.data["db_version"].startswith("Redis-2"): + act_kwargs.cluster["conf"]["cluster-enabled"] = ClusterStatus.REDIS_CLUSTER_NO act_kwargs.get_redis_payload_func = RedisActPayload.set_redis_config.__name__ acts_list.append( diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_shutdown.py b/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_shutdown.py index 77652cbfe8..6426f2a11d 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_shutdown.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_cluster_shutdown.py @@ -106,7 +106,8 @@ def redis_cluster_shutdown_flow(self): **cluster_info["redis_map"], **cluster_info["proxy_map"], "monitor_time_ms": DEFAULT_MONITOR_TIME, - "ignore_req": False, + # 集群下架时,默认先关闭,所以这个实例应该没有请求了才对,所以这里应该是强制下架 + "ignore_req": True, "ignore_keys": DEFAULT_REDIS_SYSTEM_CMDS, } act_kwargs.bk_cloud_id = cluster_info["bk_cloud_id"] diff --git a/dbm-ui/backend/flow/utils/redis/redis_act_playload.py b/dbm-ui/backend/flow/utils/redis/redis_act_playload.py index d3b23b2f61..06fa21a0d1 100644 --- a/dbm-ui/backend/flow/utils/redis/redis_act_playload.py +++ b/dbm-ui/backend/flow/utils/redis/redis_act_playload.py @@ -152,14 +152,14 @@ def __get_define_config(self, namespace: str, conf_file: str, conf_type: str) -> ) return data["content"] - def set_redis_config(self, clusterMap: dict) -> Any: + def set_redis_config(self, cluster_map: dict) -> Any: conf_items = [] - for conf_name, conf_value in clusterMap["conf"].items(): + for conf_name, conf_value in cluster_map["conf"].items(): conf_items.append({"conf_name": conf_name, "conf_value": conf_value, "op_type": OpType.UPDATE}) data = DBConfigApi.upsert_conf_item( { "conf_file_info": { - "conf_file": clusterMap["db_version"], + "conf_file": cluster_map["db_version"], "conf_type": ConfigTypeEnum.DBConf, "namespace": self.namespace, }, @@ -169,23 +169,24 @@ def set_redis_config(self, clusterMap: dict) -> Any: "req_type": ReqType.SAVE_AND_PUBLISH, "bk_biz_id": self.bk_biz_id, "level_name": LevelName.CLUSTER, - "level_value": clusterMap["domain_name"], + "level_value": cluster_map["domain_name"], } ) # 备份相关的配置,需要单独写进去 - if "cache_backup_mode" in clusterMap["backup_config"]: - set_backup_mode( - clusterMap["domain_name"], - self.bk_biz_id, - self.namespace, - clusterMap["backup_config"]["cache_backup_mode"], - ) + if "backup_config" in cluster_map: + if "cache_backup_mode" in cluster_map["backup_config"]: + set_backup_mode( + cluster_map["domain_name"], + self.bk_biz_id, + self.namespace, + cluster_map["backup_config"]["cache_backup_mode"], + ) return data - def delete_redis_config(self, clusterMap: dict): + def delete_redis_config(self, cluster_map: dict): conf_items = [ - {"conf_name": conf_name, "op_type": OpType.REMOVE} for conf_name, _ in clusterMap["conf"].items() + {"conf_name": conf_name, "op_type": OpType.REMOVE} for conf_name, _ in cluster_map["conf"].items() ] data = DBConfigApi.upsert_conf_item( { @@ -215,23 +216,23 @@ def redis_conf_names_by_cluster_type(cluster_type: str) -> list: conf_names.append("databases") return conf_names - def dts_swap_redis_config(self, clusterMap: dict): + def dts_swap_redis_config(self, cluster_map: dict): """交换源集群和目标集群的redis配置""" logger.info(_("开始交换源集群和目标集群的redis配置")) - logger.info(_("获取源集群:{} redis配置").format(clusterMap["src_cluster_domain"])) + logger.info(_("获取源集群:{} redis配置").format(cluster_map["src_cluster_domain"])) src_resp = DBConfigApi.query_conf_item( params={ - "bk_biz_id": str(clusterMap["bk_biz_id"]), + "bk_biz_id": str(cluster_map["bk_biz_id"]), "level_name": LevelName.CLUSTER, - "level_value": clusterMap["src_cluster_domain"], + "level_value": cluster_map["src_cluster_domain"], "level_info": {"module": str(DEFAULT_DB_MODULE_ID)}, - "conf_file": clusterMap["src_cluster_version"], + "conf_file": cluster_map["src_cluster_version"], "conf_type": ConfigTypeEnum.DBConf, - "namespace": clusterMap["src_cluster_type"], + "namespace": cluster_map["src_cluster_type"], "format": FormatType.MAP, } ) - src_conf_names = self.redis_conf_names_by_cluster_type(clusterMap["src_cluster_type"]) + src_conf_names = self.redis_conf_names_by_cluster_type(cluster_map["src_cluster_type"]) src_conf_items = [] for conf_name in src_conf_names: if conf_name in src_resp["content"]: @@ -239,20 +240,20 @@ def dts_swap_redis_config(self, clusterMap: dict): {"conf_name": conf_name, "conf_value": src_resp["content"][conf_name], "op_type": OpType.UPDATE} ) - logger.info(_("获取目标集群:{} redis配置").format(clusterMap["dst_cluster_domain"])) + logger.info(_("获取目标集群:{} redis配置").format(cluster_map["dst_cluster_domain"])) dst_resp = DBConfigApi.query_conf_item( params={ - "bk_biz_id": str(clusterMap["bk_biz_id"]), + "bk_biz_id": str(cluster_map["bk_biz_id"]), "level_name": LevelName.CLUSTER, - "level_value": clusterMap["dst_cluster_domain"], + "level_value": cluster_map["dst_cluster_domain"], "level_info": {"module": str(DEFAULT_DB_MODULE_ID)}, - "conf_file": clusterMap["dst_cluster_version"], + "conf_file": cluster_map["dst_cluster_version"], "conf_type": ConfigTypeEnum.DBConf, - "namespace": clusterMap["dst_cluster_type"], + "namespace": cluster_map["dst_cluster_type"], "format": FormatType.MAP, } ) - dst_conf_names = self.redis_conf_names_by_cluster_type(clusterMap["dst_cluster_type"]) + dst_conf_names = self.redis_conf_names_by_cluster_type(cluster_map["dst_cluster_type"]) dst_conf_items = [] for conf_name in dst_conf_names: if conf_name in dst_resp["content"]: @@ -270,7 +271,7 @@ def dts_swap_redis_config(self, clusterMap: dict): "level_info": {"module": str(DEFAULT_DB_MODULE_ID)}, "confirm": DEFAULT_CONFIG_CONFIRM, "req_type": ReqType.SAVE_AND_PUBLISH, - "bk_biz_id": str(clusterMap["bk_biz_id"]), + "bk_biz_id": str(cluster_map["bk_biz_id"]), "level_name": LevelName.CLUSTER, "level_value": "", # 需要替换成真实值 } @@ -278,51 +279,51 @@ def dts_swap_redis_config(self, clusterMap: dict): if src_conf_names != dst_conf_names: # 源集群、目标集群类型有变化, 先删除原有的配置,再更新配置,避免残留 src_remove_items = [{"conf_name": conf_name, "op_type": OpType.REMOVE} for conf_name in src_conf_names] - upsert_param["conf_file_info"]["namespace"] = clusterMap["src_cluster_type"] - upsert_param["conf_file_info"]["conf_file"] = clusterMap["src_cluster_version"] + upsert_param["conf_file_info"]["namespace"] = cluster_map["src_cluster_type"] + upsert_param["conf_file_info"]["conf_file"] = cluster_map["src_cluster_version"] upsert_param["conf_items"] = src_remove_items - upsert_param["level_value"] = clusterMap["src_cluster_domain"] - logger.info(_("删除源集群:{} redis配置,upsert_param:{}".format(clusterMap["src_cluster_domain"], upsert_param))) + upsert_param["level_value"] = cluster_map["src_cluster_domain"] + logger.info(_("删除源集群:{} redis配置,upsert_param:{}".format(cluster_map["src_cluster_domain"], upsert_param))) DBConfigApi.upsert_conf_item(upsert_param) dst_remove_items = [{"conf_name": conf_name, "op_type": OpType.REMOVE} for conf_name in dst_conf_names] - upsert_param["conf_file_info"]["namespace"] = clusterMap["dst_cluster_type"] - upsert_param["conf_file_info"]["conf_file"] = clusterMap["dst_cluster_version"] + upsert_param["conf_file_info"]["namespace"] = cluster_map["dst_cluster_type"] + upsert_param["conf_file_info"]["conf_file"] = cluster_map["dst_cluster_version"] upsert_param["conf_items"] = dst_remove_items - upsert_param["level_value"] = clusterMap["dst_cluster_domain"] - logger.info(_("删除目标集群:{} redis配置,upsert_param:{}").format(clusterMap["dst_cluster_domain"], upsert_param)) + upsert_param["level_value"] = cluster_map["dst_cluster_domain"] + logger.info(_("删除目标集群:{} redis配置,upsert_param:{}").format(cluster_map["dst_cluster_domain"], upsert_param)) DBConfigApi.upsert_conf_item(upsert_param) time.sleep(2) # 源集群 写入目标集群的配置 - upsert_param["conf_file_info"]["namespace"] = clusterMap["dst_cluster_type"] - upsert_param["conf_file_info"]["conf_file"] = clusterMap["dst_cluster_version"] + upsert_param["conf_file_info"]["namespace"] = cluster_map["dst_cluster_type"] + upsert_param["conf_file_info"]["conf_file"] = cluster_map["dst_cluster_version"] upsert_param["conf_items"] = dst_conf_items - upsert_param["level_value"] = clusterMap["src_cluster_domain"] + upsert_param["level_value"] = cluster_map["src_cluster_domain"] logger.info(_("更新源集群redis配置 为 目标集群的配置,upsert_param:{}".format(upsert_param))) DBConfigApi.upsert_conf_item(upsert_param) # 目标集群 写入源集群的配置 - upsert_param["conf_file_info"]["namespace"] = clusterMap["src_cluster_type"] - upsert_param["conf_file_info"]["conf_file"] = clusterMap["src_cluster_version"] + upsert_param["conf_file_info"]["namespace"] = cluster_map["src_cluster_type"] + upsert_param["conf_file_info"]["conf_file"] = cluster_map["src_cluster_version"] upsert_param["conf_items"] = src_conf_items - upsert_param["level_value"] = clusterMap["dst_cluster_domain"] + upsert_param["level_value"] = cluster_map["dst_cluster_domain"] logger.info(_("更新目标集群redis配置 为 源集群的配置,upsert_param:{}".format(upsert_param))) DBConfigApi.upsert_conf_item(upsert_param) # 交换源集群和目标集群的redis 密码,proxy密码不会变化 - src_passwd_ret = PayloadHandler.redis_get_password_by_domain(clusterMap["src_cluster_domain"]) - dst_passwd_ret = PayloadHandler.redis_get_password_by_domain(clusterMap["dst_cluster_domain"]) + src_passwd_ret = PayloadHandler.redis_get_password_by_domain(cluster_map["src_cluster_domain"]) + dst_passwd_ret = PayloadHandler.redis_get_password_by_domain(cluster_map["dst_cluster_domain"]) PayloadHandler.redis_save_password_by_domain( - immute_domain=clusterMap["src_cluster_domain"], + immute_domain=cluster_map["src_cluster_domain"], redis_password=dst_passwd_ret.get("redis_password"), ) PayloadHandler.redis_save_password_by_domain( - immute_domain=clusterMap["dst_cluster_domain"], + immute_domain=cluster_map["dst_cluster_domain"], redis_password=src_passwd_ret.get("redis_password"), ) - def delete_proxy_config(self, clusterMap: dict): + def delete_proxy_config(self, cluster_map: dict): conf_items = [ - {"conf_name": conf_name, "op_type": OpType.REMOVE} for conf_name, _ in clusterMap["conf"].items() + {"conf_name": conf_name, "op_type": OpType.REMOVE} for conf_name, _ in cluster_map["conf"].items() ] data = DBConfigApi.upsert_conf_item( { @@ -372,20 +373,20 @@ def __get_cluster_config(self, domain_name: str, db_version: str, conf_type: str return data["content"] - def set_proxy_config(self, clusterMap: dict) -> Any: + def set_proxy_config(self, cluster_map: dict) -> Any: """ 集群初始化的时候twemproxy没做变动,直接写入集群就OK """ # 密码随机化 PayloadHandler.redis_save_password_by_domain( - immute_domain=clusterMap["domain_name"], - redis_password=clusterMap["pwd_conf"]["redis_pwd"], - redis_proxy_password=clusterMap["pwd_conf"]["proxy_pwd"], - redis_proxy_admin_password=clusterMap["pwd_conf"]["proxy_admin_pwd"], + immute_domain=cluster_map["domain_name"], + redis_password=cluster_map["pwd_conf"]["redis_pwd"], + redis_proxy_password=cluster_map["pwd_conf"]["proxy_pwd"], + redis_proxy_admin_password=cluster_map["pwd_conf"]["proxy_admin_pwd"], ) conf_items = [] - for conf_name, conf_value in clusterMap["conf"].items(): + for conf_name, conf_value in cluster_map["conf"].items(): conf_items.append({"conf_name": conf_name, "conf_value": conf_value, "op_type": OpType.UPDATE}) data = DBConfigApi.upsert_conf_item( { @@ -400,33 +401,33 @@ def set_proxy_config(self, clusterMap: dict) -> Any: "req_type": ReqType.SAVE_AND_PUBLISH, "bk_biz_id": self.bk_biz_id, "level_name": LevelName.CLUSTER, - "level_value": clusterMap["domain_name"], + "level_value": cluster_map["domain_name"], } ) return data - def dts_swap_proxy_config(self, clusterMap: dict) -> Any: + def dts_swap_proxy_config(self, cluster_map: dict) -> Any: """ 交换源集群和目标集群 dbconfig 中的proxy版本信息,有可能 twemproxy集群 切换到 predixy集群 """ src_proxy_conf_names = ["port"] dst_proxy_conf_names = ["port"] - # if is_twemproxy_proxy_type(clusterMap["src_cluster_type"]): + # if is_twemproxy_proxy_type(cluster_map["src_cluster_type"]): # src_proxy_conf_names.append("hash_tag") - # if is_twemproxy_proxy_type(clusterMap["dst_cluster_type"]): + # if is_twemproxy_proxy_type(cluster_map["dst_cluster_type"]): # dst_proxy_conf_names.append("hash_tag") logger.info(_("交换源集群和目标集群 dbconfig 中的proxy版本信息")) - logger.info(_("获取源集群:{} proxy配置").format(clusterMap["src_cluster_domain"])) + logger.info(_("获取源集群:{} proxy配置").format(cluster_map["src_cluster_domain"])) src_resp = DBConfigApi.query_conf_item( params={ - "bk_biz_id": str(clusterMap["bk_biz_id"]), + "bk_biz_id": str(cluster_map["bk_biz_id"]), "level_name": LevelName.CLUSTER, - "level_value": clusterMap["src_cluster_domain"], + "level_value": cluster_map["src_cluster_domain"], "level_info": {"module": str(DEFAULT_DB_MODULE_ID)}, - "conf_file": clusterMap["src_proxy_version"], + "conf_file": cluster_map["src_proxy_version"], "conf_type": ConfigTypeEnum.ProxyConf, - "namespace": clusterMap["src_cluster_type"], + "namespace": cluster_map["src_cluster_type"], "format": FormatType.MAP, } ) @@ -437,16 +438,16 @@ def dts_swap_proxy_config(self, clusterMap: dict) -> Any: ) logger.info(_("src_conf_upsert_items==>{}".format(src_conf_upsert_items))) - logger.info(_("获取目标集群:{} proxy配置").format(clusterMap["dst_cluster_domain"])) + logger.info(_("获取目标集群:{} proxy配置").format(cluster_map["dst_cluster_domain"])) dst_resp = DBConfigApi.query_conf_item( params={ - "bk_biz_id": str(clusterMap["bk_biz_id"]), + "bk_biz_id": str(cluster_map["bk_biz_id"]), "level_name": LevelName.CLUSTER, - "level_value": clusterMap["dst_cluster_domain"], + "level_value": cluster_map["dst_cluster_domain"], "level_info": {"module": str(DEFAULT_DB_MODULE_ID)}, - "conf_file": clusterMap["dst_proxy_version"], + "conf_file": cluster_map["dst_proxy_version"], "conf_type": ConfigTypeEnum.ProxyConf, - "namespace": clusterMap["dst_cluster_type"], + "namespace": cluster_map["dst_cluster_type"], "format": FormatType.MAP, } ) @@ -467,7 +468,7 @@ def dts_swap_proxy_config(self, clusterMap: dict) -> Any: "level_info": {"module": str(DEFAULT_DB_MODULE_ID)}, "confirm": DEFAULT_CONFIG_CONFIRM, "req_type": ReqType.SAVE_AND_PUBLISH, - "bk_biz_id": str(clusterMap["bk_biz_id"]), + "bk_biz_id": str(cluster_map["bk_biz_id"]), "level_name": LevelName.CLUSTER, "level_value": "", # 需要替换成真实值 } @@ -477,12 +478,12 @@ def dts_swap_proxy_config(self, clusterMap: dict) -> Any: remove_items.append({"conf_name": conf_name, "op_type": OpType.REMOVE}) # 删除源集群的proxy配置 src_remove_param = copy.deepcopy(upsert_param) - src_remove_param["conf_file_info"]["conf_file"] = clusterMap["src_proxy_version"] - src_remove_param["conf_file_info"]["namespace"] = clusterMap["src_cluster_type"] + src_remove_param["conf_file_info"]["conf_file"] = cluster_map["src_proxy_version"] + src_remove_param["conf_file_info"]["namespace"] = cluster_map["src_cluster_type"] src_remove_param["conf_items"] = remove_items - src_remove_param["level_value"] = clusterMap["src_cluster_domain"] + src_remove_param["level_value"] = cluster_map["src_cluster_domain"] logger.info( - _("删除源集群:{} proxy配置,src_remove_param:{}").format(clusterMap["src_cluster_domain"], src_remove_param) + _("删除源集群:{} proxy配置,src_remove_param:{}").format(cluster_map["src_cluster_domain"], src_remove_param) ) DBConfigApi.upsert_conf_item(src_remove_param) @@ -491,12 +492,12 @@ def dts_swap_proxy_config(self, clusterMap: dict) -> Any: remove_items.append({"conf_name": conf_name, "op_type": OpType.REMOVE}) # 删除目标集群的proxy配置 dst_remove_param = copy.deepcopy(upsert_param) - dst_remove_param["conf_file_info"]["conf_file"] = clusterMap["dst_proxy_version"] - dst_remove_param["conf_file_info"]["namespace"] = clusterMap["dst_cluster_type"] + dst_remove_param["conf_file_info"]["conf_file"] = cluster_map["dst_proxy_version"] + dst_remove_param["conf_file_info"]["namespace"] = cluster_map["dst_cluster_type"] dst_remove_param["conf_items"] = remove_items - dst_remove_param["level_value"] = clusterMap["dst_cluster_domain"] + dst_remove_param["level_value"] = cluster_map["dst_cluster_domain"] logger.info( - _("删除目标集群:{} proxy配置,dst_remove_param:{}").format(clusterMap["dst_cluster_domain"], dst_remove_param) + _("删除目标集群:{} proxy配置,dst_remove_param:{}").format(cluster_map["dst_cluster_domain"], dst_remove_param) ) DBConfigApi.upsert_conf_item(dst_remove_param) @@ -504,26 +505,26 @@ def dts_swap_proxy_config(self, clusterMap: dict) -> Any: # 更新源集群的proxy版本信息 src_upsert_param = copy.deepcopy(upsert_param) - src_upsert_param["conf_file_info"]["conf_file"] = clusterMap["dst_proxy_version"] # 替换成目标集群的proxy版本 - src_upsert_param["conf_file_info"]["namespace"] = clusterMap["dst_cluster_type"] + src_upsert_param["conf_file_info"]["conf_file"] = cluster_map["dst_proxy_version"] # 替换成目标集群的proxy版本 + src_upsert_param["conf_file_info"]["namespace"] = cluster_map["dst_cluster_type"] src_upsert_param["conf_items"] = src_conf_upsert_items - src_upsert_param["level_value"] = clusterMap["src_cluster_domain"] + src_upsert_param["level_value"] = cluster_map["src_cluster_domain"] logger.info( _("更新源集群:{} dbconfig 中proxy版本等信息,src_upsert_param:{}").format( - clusterMap["src_cluster_domain"], src_upsert_param + cluster_map["src_cluster_domain"], src_upsert_param ) ) DBConfigApi.upsert_conf_item(src_upsert_param) # 更新目标集群的proxy版本信息 dst_upsert_param = copy.deepcopy(upsert_param) - dst_upsert_param["conf_file_info"]["conf_file"] = clusterMap["src_proxy_version"] # 替换成源集群的proxy版本 - dst_upsert_param["conf_file_info"]["namespace"] = clusterMap["src_cluster_type"] + dst_upsert_param["conf_file_info"]["conf_file"] = cluster_map["src_proxy_version"] # 替换成源集群的proxy版本 + dst_upsert_param["conf_file_info"]["namespace"] = cluster_map["src_cluster_type"] dst_upsert_param["conf_items"] = dst_conf_upsert_items - dst_upsert_param["level_value"] = clusterMap["dst_cluster_domain"] + dst_upsert_param["level_value"] = cluster_map["dst_cluster_domain"] logger.info( _("更新目标集群:{} dbconfig 中proxy版本等信息,dst_upsert_param:{}").format( - clusterMap["dst_cluster_domain"], dst_upsert_param + cluster_map["dst_cluster_domain"], dst_upsert_param ) ) DBConfigApi.upsert_conf_item(dst_upsert_param)