Skip to content

Commit

Permalink
fix(mongodb): mongodb安装修复bug TencentBlueKing#3353
Browse files Browse the repository at this point in the history
  • Loading branch information
yyhenryyy authored and iSecloud committed Feb 27, 2024
1 parent cbaff25 commit ddcab02
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"]})
# 找到主节点
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"] = []
Expand Down Expand Up @@ -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"],
Expand Down
8 changes: 6 additions & 2 deletions dbm-ui/backend/flow/utils/mongodb/mongodb_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ddcab02

Please sign in to comment.