From 88c474cf775b330c5b57d6eaee68b54a4c8b19e6 Mon Sep 17 00:00:00 2001 From: OMG-By <504094596@qq.com> Date: Wed, 11 Sep 2024 17:59:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(redis):=20rediscluster=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=98=E6=9B=B4bug=20#6788?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bamboo/scene/redis/redis_backend_scale.py | 6 +-- .../flow/utils/redis/redis_act_playload.py | 46 ++++++++----------- 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_backend_scale.py b/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_backend_scale.py index a4f2945cba..0df8a7f956 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_backend_scale.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/redis/redis_backend_scale.py @@ -192,7 +192,7 @@ def generate_sync_relation(self, act_kwargs, master_ips, slave_ips, ins_num, sup """ 计算新老实例对应关系 可能一对多,也可能多对一 - 20250806 需要兼容本地扩缩容场景:多余的实例数,可能是在老机器上 + 20240806 需要兼容本地扩缩容场景:多余的实例数,可能是在老机器上 - master_ips: 新机器master列表 - slave_ips: 新机器slave列表 - ins_num: 单台机器部署的最小实例数(有可能+1) @@ -472,8 +472,6 @@ def redis_backend_scale_flow(self): redis_sync_sub_pipelines = [] for sync_params in sync_relations: - if act_kwargs.cluster["cluster_type"] == ClusterType.TendisTwemproxyRedisInstance: - pass sub_builder = RedisMakeSyncAtomJob(self.root_id, self.data, act_kwargs, sync_params) redis_sync_sub_pipelines.append(sub_builder) sub_pipeline.add_parallel_sub_pipeline(sub_flow_list=redis_sync_sub_pipelines) @@ -490,8 +488,6 @@ def redis_backend_scale_flow(self): redis_sync_sub_pipelines = [] for sync_params in sync_relations2: - if act_kwargs.cluster["cluster_type"] == ClusterType.TendisTwemproxyRedisInstance: - pass sub_builder = RedisMakeSyncAtomJob(self.root_id, self.data, act_kwargs, sync_params) redis_sync_sub_pipelines.append(sub_builder) sub_pipeline.add_parallel_sub_pipeline(sub_flow_list=redis_sync_sub_pipelines) 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 b660d01af3..5fec5403ae 100644 --- a/dbm-ui/backend/flow/utils/redis/redis_act_playload.py +++ b/dbm-ui/backend/flow/utils/redis/redis_act_playload.py @@ -997,14 +997,13 @@ def redis_flush_data_payload(self, **kwargs) -> dict: ip = kwargs["ip"] params = kwargs["params"] domain_name = params.get("domain_name", self.cluster.get("domain_name", "")) - db_version = params.get("db_version", self.cluster.get("db_version", "")) cluster_type = params.get("cluster_type", self.cluster.get("cluster_type", "")) ports = params.get("ports", self.cluster.get(ip, [])) force = params.get("force", self.cluster.get("force", False)) db_list = params.get("db_list", self.cluster.get("db_list", [0])) flushall = params.get("flushall", self.cluster.get("flushall", True)) - redis_config = self.__get_cluster_config(domain_name, db_version, ConfigTypeEnum.DBConf) + passwd_ret = PayloadHandler.redis_get_password_by_domain(domain_name) return { "db_type": DBActuatorTypeEnum.Redis.value, "action": DBActuatorTypeEnum.Redis.value + "_" + RedisActuatorActionEnum.FlushData.value, @@ -1013,7 +1012,7 @@ def redis_flush_data_payload(self, **kwargs) -> dict: "db_type": cluster_type, "ports": ports, "is_force": force, - "password": redis_config["requirepass"], + "password": passwd_ret.get("redis_password"), "db_list": db_list, "is_flush_all": flushall, }, @@ -1561,22 +1560,16 @@ def redis__switch_4_scene(self, **kwargs) -> dict: "switch_condition":{}, } """ - params, proxy_version = kwargs["params"], "" + params = kwargs["params"] self.namespace = params["cluster_type"] cluster_meta = nosqlcomm.other.get_cluster_detail(cluster_id=params["cluster_id"])[0] if self.namespace == ClusterType.RedisInstance.value: - cluster_config = self.__get_cluster_config( - params["immute_domain"], params.get("db_version", ""), ConfigTypeEnum.DBConf - ) - cluster_meta["storage_pass"] = cluster_config["requirepass"] + passwd_ret = PayloadHandler.redis_get_password_by_domain(params["immute_domain"]) + cluster_meta["storage_pass"] = passwd_ret.get("redis_password") else: - if is_twemproxy_proxy_type(self.namespace): - proxy_version = ConfigFileEnum.Twemproxy - elif is_predixy_proxy_type(self.namespace): - proxy_version = ConfigFileEnum.Predixy - proxy_config = self.__get_cluster_config(params["immute_domain"], proxy_version, ConfigTypeEnum.ProxyConf) - cluster_meta["proxy_pass"] = proxy_config["password"] - cluster_meta["storage_pass"] = proxy_config["redis_password"] + passwd_ret = PayloadHandler.redis_get_password_by_domain(params["immute_domain"]) + cluster_meta["proxy_pass"] = passwd_ret.get("redis_proxy_password") + cluster_meta["storage_pass"] = passwd_ret.get("redis_password") logger.info("switch cluster {}, switch infos : {}".format(params["immute_domain"], params["switch_info"])) return { @@ -1767,18 +1760,17 @@ def redis_tendisssd_dr_restore_4_scene(self, **kwargs) -> dict: """ params = kwargs["params"] self.namespace = params["cluster_type"] - proxy_config = self.__get_cluster_config(params["immute_domain"], self.proxy_version, ConfigTypeEnum.ProxyConf) - + passwd_ret = PayloadHandler.redis_get_password_by_domain(params["immute_domain"]) return { "db_type": DBActuatorTypeEnum.Redis.value, "action": DBActuatorTypeEnum.TendisSSD.value + "_" + RedisActuatorActionEnum.DR_RESTORE.value, "payload": { "master_ip": params["master_ip"], "master_ports": params["master_ports"], - "master_auth": proxy_config["redis_password"], + "master_auth": passwd_ret.get("redis_password"), "slave_ip": params["slave_ip"], "slave_ports": params["slave_ports"], - "slave_password": proxy_config["redis_password"], + "slave_password": passwd_ret.get("redis_password"), "task_dir": "/data/dbbak", "backup_dir": "/data/dbbak", }, @@ -1853,7 +1845,7 @@ def rollback_clustermeet_payload(self, **kwargs) -> dict: 数据构造 rediscluster 集群建立 """ params = kwargs["params"] - redis_config = self.__get_cluster_config(params["immute_domain"], params["db_version"], ConfigTypeEnum.DBConf) + passwd_ret = PayloadHandler.redis_get_password_by_domain(params["immute_domain"]) bacth_pairs = [] for instance in params["all_instance"]: ip, port = instance.split(":") @@ -1866,7 +1858,7 @@ def rollback_clustermeet_payload(self, **kwargs) -> dict: "db_type": DBActuatorTypeEnum.Redis.value, "action": RedisActuatorActionEnum.CLUSTER_MEET.value, "payload": { - "password": redis_config["requirepass"], + "password": passwd_ret.get("redis_password"), "slots_auto_assign": True, "replica_pairs": bacth_pairs, }, @@ -1898,7 +1890,7 @@ def clustermeet_check_payload(self, **kwargs) -> dict: 数据构造 rediscluster meet建立集群关系并检查集群状态 """ params = kwargs["params"] - redis_config = self.__get_cluster_config(params["immute_domain"], params["db_version"], ConfigTypeEnum.DBConf) + passwd_ret = PayloadHandler.redis_get_password_by_domain(params["immute_domain"]) bacth_pairs = [] for instance in params["all_instance"]: ip, port = instance.split(IP_PORT_DIVIDER) @@ -1912,7 +1904,7 @@ def clustermeet_check_payload(self, **kwargs) -> dict: "db_type": DBActuatorTypeEnum.Redis.value, "action": RedisActuatorActionEnum.CLUSTER_MEET_CHECK.value, "payload": { - "password": redis_config["requirepass"], + "password": passwd_ret.get("redis_password"), "replica_pairs": bacth_pairs, }, } @@ -1934,7 +1926,7 @@ def redis_cluster_meet_4_scene(self, **kwargs) -> dict: } """ params = kwargs["params"] - redis_config = self.__get_cluster_config(params["immute_domain"], params["db_version"], ConfigTypeEnum.DBConf) + passwd_ret = PayloadHandler.redis_get_password_by_domain(params["immute_domain"]) cluster = Cluster.objects.get(immute_domain=params["immute_domain"]) cluster_info = metaApi.cluster.nosqlcomm.get_cluster_detail(cluster.id)[0] bacth_pairs = [] @@ -1950,7 +1942,7 @@ def redis_cluster_meet_4_scene(self, **kwargs) -> dict: "db_type": DBActuatorTypeEnum.Redis.value, "action": RedisActuatorActionEnum.CLUSTER_MEET.value, "payload": { - "password": redis_config["requirepass"], + "password": passwd_ret.get("redis_password"), "replica_pairs": bacth_pairs, "slots_auto_assign": False, "use_for_expansion": False, @@ -1966,7 +1958,7 @@ def redis_cluster_forget_4_scene(self, **kwargs) -> dict: } """ params = kwargs["params"] - redis_config = self.__get_cluster_config(params["immute_domain"], params["db_version"], ConfigTypeEnum.DBConf) + passwd_ret = PayloadHandler.redis_get_password_by_domain(params["immute_domain"]) cluster = Cluster.objects.get(immute_domain=params["immute_domain"]) cluster_info = metaApi.cluster.nosqlcomm.get_cluster_detail(cluster.id)[0] @@ -1975,7 +1967,7 @@ def redis_cluster_forget_4_scene(self, **kwargs) -> dict: "action": DBActuatorTypeEnum.Redis.value + "_" + RedisActuatorActionEnum.ClusterForget.value, "payload": { "cluster_meta": { - "storage_pass": redis_config["requirepass"], + "storage_pass": passwd_ret.get("redis_password"), "immute_domain": cluster_info["immute_domain"], "cluster_type": cluster_info["cluster_type"], "redis_master_set": cluster_info["redis_master_set"],