Skip to content

Commit

Permalink
feat(mongodb): mongos自愈,mongo实例下架 TencentBlueKing#7010
Browse files Browse the repository at this point in the history
  • Loading branch information
yyhenryyy committed Oct 18, 2024
1 parent 21151b8 commit 4137a1e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def get_public_data(self) -> Dict:
"bk_app_abbr": AppCache.objects.get(bk_biz_id=bk_biz_id).db_app_abbr,
"created_by": self.data["created_by"],
"ticket_type": self.data["ticket_type"],
"db_version": "",
"infos": {"MongoReplicaSet": [], "MongoShardedCluster": []},
}

Expand All @@ -56,6 +57,7 @@ def shard_get_data(self) -> Dict:
bk_cloud_id = self.autofix_info["bk_cloud_id"]
cluster_id = self.autofix_info["cluster_ids"][0]
cluster_info = MongoRepository().fetch_one_cluster(withDomain=False, id=cluster_id)
flow_parameter["db_version"] = cluster_info.major_version
config = cluster_info.get_config()
shards = cluster_info.get_shards()
cluster = {}
Expand Down Expand Up @@ -143,6 +145,7 @@ def rs_get_data(self) -> Dict:
instances = []
for cluster_id in cluster_ids:
cluster_info = MongoRepository().fetch_one_cluster(withDomain=True, id=cluster_id)
flow_parameter["db_version"] = cluster_info.major_version
for member in cluster_info.get_shards()[0].members:
if mongod["ip"] == member.ip:
instances.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ def mongos_autofix(root_id: str, ticket_data: Optional[Dict], sub_sub_kwargs: Ac
sub_sub_get_kwargs.mongos_info["conf_set_id"] = sub_sub_get_kwargs.get_config_set_name_replace(
cluster_id=cluster_id
)
# 获取db版本
db_version = sub_sub_get_kwargs.db_instance["db_version"]
# db大版本
sub_sub_get_kwargs.db_main_version = str(db_version.split("-")[1].split(".")[0])
# db发行版本
sub_sub_get_kwargs.db_release_version = db_version
# db发行
sub_sub_get_kwargs.db_release = db_version.split("-")[0]
# db版本
sub_sub_get_kwargs.payload["db_version"] = db_version.split("-")[1]
sub_sub_get_kwargs.cluster_type = ClusterType.MongoShardedCluster.value
sub_sub_get_kwargs.payload["key_file"] = sub_sub_get_kwargs.get_conf(
cluster_name=sub_sub_get_kwargs.db_instance["cluster_name"]
Expand Down

0 comments on commit 4137a1e

Please sign in to comment.