diff --git a/dbm-ui/backend/db_meta/api/cluster/nosqlcomm/create_instances.py b/dbm-ui/backend/db_meta/api/cluster/nosqlcomm/create_instances.py index 2255072531..8ac5a781b6 100644 --- a/dbm-ui/backend/db_meta/api/cluster/nosqlcomm/create_instances.py +++ b/dbm-ui/backend/db_meta/api/cluster/nosqlcomm/create_instances.py @@ -31,7 +31,7 @@ def create_mongo_mutil_instances(bk_biz_id, bk_cloud_id, machine_type, inst_pair "bk_cloud_id": bk_cloud_id, "machine_type": machine_type, "spec_id": spec_config.get(machine_type, {}).get("spec_id", 0), - "spec_config": spec_config.get(machine_type, {}), + "spec_config": spec_config.get(machine_type, {}).get("spec_config", {}), } instances.append({"ip": storage["ip"], "port": storage["port"], "instance_role": storage["role"]}) # 找到主节点 diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/mongodb/sub_task/mongod_replace.py b/dbm-ui/backend/flow/engine/bamboo/scene/mongodb/sub_task/mongod_replace.py index bf5c612c48..11e2ac476e 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/mongodb/sub_task/mongod_replace.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/mongodb/sub_task/mongod_replace.py @@ -53,6 +53,9 @@ def mongod_replace( cluster_name = sub_sub_get_kwargs.db_instance["seg_range"] sub_sub_get_kwargs.payload["cluster_type"] = ClusterType.MongoShardedCluster.value sub_sub_get_kwargs.payload["set_id"] = sub_sub_get_kwargs.db_instance["seg_range"] + sub_sub_get_kwargs.payload["key_file"] = sub_sub_get_kwargs.get_key_file( + cluster_name=sub_sub_get_kwargs.db_instance["cluster_name"] + ) sub_sub_get_kwargs.payload["config_nodes"] = [] sub_sub_get_kwargs.payload["shards_nodes"] = [] sub_sub_get_kwargs.payload["mongos_nodes"] = [] @@ -83,10 +86,10 @@ def mongod_replace( cluster_name = sub_sub_get_kwargs.db_instance["cluster_name"] sub_sub_get_kwargs.payload["cluster_type"] = ClusterType.MongoReplicaSet.value sub_sub_get_kwargs.payload["set_id"] = sub_sub_get_kwargs.db_instance["cluster_name"] + sub_sub_get_kwargs.replicaset_info["key_file"] = sub_sub_get_kwargs.get_key_file( + cluster_name=sub_sub_get_kwargs.db_instance["cluster_name"] + ) sub_sub_get_kwargs.replicaset_info["set_id"] = cluster_name - sub_sub_get_kwargs.payload["key_file"] = sub_sub_get_kwargs.get_key_file( - cluster_name=sub_sub_get_kwargs.db_instance["cluster_name"] - ) sub_sub_get_kwargs.replicaset_info["nodes"] = [ { "ip": new_node["ip"], diff --git a/dbm-ui/backend/flow/utils/mongodb/mongodb_dataclass.py b/dbm-ui/backend/flow/utils/mongodb/mongodb_dataclass.py index c4f35ec531..f920fadf50 100644 --- a/dbm-ui/backend/flow/utils/mongodb/mongodb_dataclass.py +++ b/dbm-ui/backend/flow/utils/mongodb/mongodb_dataclass.py @@ -267,6 +267,10 @@ def get_install_mongod_kwargs(self, node: dict, cluster_role: str) -> dict: self.get_mongodb_conf() self.db_conf["cacheSizeGB"] = self.replicaset_info["cacheSizeGB"] self.db_conf["oplogSizeMB"] = self.replicaset_info["oplogSizeMB"] + if cluster_role: + key_file = self.payload["key_file"] + else: + key_file = self.replicaset_info["key_file"] return { "set_trans_data_dataclass": CommonContext.__name__, "get_trans_data_ip_var": None, @@ -286,7 +290,7 @@ def get_install_mongod_kwargs(self, node: dict, cluster_role: str) -> dict: "instanceType": MongoDBInstanceType.MongoD, "app": self.payload["app"], "setId": self.replicaset_info["set_id"], - "keyFile": self.payload["key_file"], + "keyFile": key_file, "auth": True, "clusterRole": cluster_role, "dbConfig": self.db_conf, @@ -983,7 +987,7 @@ def get_host_replace(self, mongodb_type: str, info: dict): # 目标ip hosts.append({"ip": info["target"]["ip"], "bk_cloud_id": info["target"]["bk_cloud_id"]}) # db版本 - self.payload["db_version"] = info["mongodb"][0]["db_version"] + self.payload["db_version"] = info["instances"][0]["db_version"] self.db_main_version = self.payload["db_version"].split(".")[0] elif mongodb_type == ClusterType.MongoShardedCluster.value: