Skip to content

Commit

Permalink
fix(mongodb): 修复禁用bug,容量变更、整机替换添加安装dbmon #8292
Browse files Browse the repository at this point in the history
  • Loading branch information
yyhenryyy authored and iSecloud committed Dec 2, 2024
1 parent 5616b20 commit d5fb4e1
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def cluster_enable_disable(

# 设置参数
sub_get_kwargs.payload["app"] = sub_get_kwargs.payload["bk_app_abbr"]
cluster_type = sub_get_kwargs.payload["cluster_type"]

# 获取集群信息
sub_get_kwargs.get_cluster_info_deinstall(cluster_id=cluster_id)
cluster_type = sub_get_kwargs.payload["cluster_type"]

# 修改实例状态
kwargs = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from backend.db_meta.enums.cluster_type import ClusterType
from backend.flow.engine.bamboo.scene.common.builder import SubBuilder
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install import install_plugin
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install_dbmon import add_install_dbmon
from backend.flow.plugins.components.collections.mongodb.exec_actuator_job import ExecuteDBActuatorJobComponent
from backend.flow.plugins.components.collections.mongodb.send_media import ExecSendMediaOperationComponent
from backend.flow.utils.mongodb.mongodb_dataclass import ActKwargs
Expand Down Expand Up @@ -103,4 +104,16 @@ def cluster_increase_node(root_id: str, ticket_data: Optional[Dict], sub_kwargs:
sub_pipelines.append(sub_sub_pipeline)
sub_pipeline.add_parallel_sub_pipeline(sub_flow_list=sub_pipelines)

# 安装dbmon
ip_list = sub_get_kwargs.payload["plugin_hosts"]
exec_ips = [host["ip"] for host in ip_list]
add_install_dbmon(
root_id=root_id,
flow_data=ticket_data,
pipeline=sub_pipeline,
iplist=exec_ips,
bk_cloud_id=ip_list[0]["bk_cloud_id"],
allow_empty_instance=True,
)

return sub_pipeline.build_sub_process(sub_name=_("MongoDB--{}增加节点".format(sub_get_kwargs.payload["cluster_name"])))
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from backend.flow.consts import MongoDBInstanceType, MongoDBManagerUser
from backend.flow.engine.bamboo.scene.common.builder import SubBuilder
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install import install_plugin
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install_dbmon import add_install_dbmon
from backend.flow.plugins.components.collections.mongodb.add_domain_to_dns import ExecAddDomainToDnsOperationComponent
from backend.flow.plugins.components.collections.mongodb.add_password_to_db import (
ExecAddPasswordToDBOperationComponent,
Expand Down Expand Up @@ -229,6 +230,18 @@ def mongos_autofix(root_id: str, ticket_data: Optional[Dict], sub_sub_kwargs: Ac
kwargs=kwargs,
)

# 安装dbmon
ip_list = sub_sub_get_kwargs.payload["plugin_hosts"]
exec_ips = [host["ip"] for host in ip_list]
add_install_dbmon(
root_id=root_id,
flow_data=ticket_data,
pipeline=sub_sub_pipeline,
iplist=exec_ips,
bk_cloud_id=ip_list[0]["bk_cloud_id"],
allow_empty_instance=True,
)

# 老实例提下架单
kwargs = {
"infos": sub_sub_get_kwargs.payload["nodes"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from backend.flow.consts import MongoDBClusterRole, MongoDBInstanceType
from backend.flow.engine.bamboo.scene.common.builder import SubBuilder
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install import install_plugin
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install_dbmon import add_install_dbmon
from backend.flow.plugins.components.collections.mongodb.exec_actuator_job import ExecuteDBActuatorJobComponent
from backend.flow.plugins.components.collections.mongodb.mongodb_cmr_4_meta import CMRMongoDBMetaComponent
from backend.flow.plugins.components.collections.mongodb.send_media import ExecSendMediaOperationComponent
Expand Down Expand Up @@ -143,4 +144,15 @@ def cluster_replace(root_id: str, ticket_data: Optional[Dict], sub_kwargs: ActKw
sub_pipeline.add_act(
act_name=_("MongoDB-mongos修改meta"), act_component_code=CMRMongoDBMetaComponent.code, kwargs=kwargs
)
# 安装dbmon
ip_list = sub_get_kwargs.payload["plugin_hosts"]
exec_ips = [host["ip"] for host in ip_list]
add_install_dbmon(
root_id=root_id,
flow_data=ticket_data,
pipeline=sub_pipeline,
iplist=exec_ips,
bk_cloud_id=ip_list[0]["bk_cloud_id"],
allow_empty_instance=True,
)
return sub_pipeline.build_sub_process(sub_name=_("MongoDB--cluster整机替换"))
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from backend.flow.consts import MongoDBClusterRole
from backend.flow.engine.bamboo.scene.common.builder import SubBuilder
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install import install_plugin
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install_dbmon import add_install_dbmon
from backend.flow.plugins.components.collections.mongodb.exec_actuator_job import ExecuteDBActuatorJobComponent
from backend.flow.plugins.components.collections.mongodb.send_media import ExecSendMediaOperationComponent
from backend.flow.utils.mongodb.mongodb_dataclass import ActKwargs
Expand Down Expand Up @@ -78,4 +79,16 @@ def cluster_scale(root_id: str, ticket_data: Optional[Dict], sub_kwargs: ActKwar
sub_sub_pipelines.append(sub_sub_pipeline)
sub_pipeline.add_parallel_sub_pipeline(sub_sub_pipelines)

# 安装dbmon
ip_list = sub_get_kwargs.payload["plugin_hosts"]
exec_ips = [host["ip"] for host in ip_list]
add_install_dbmon(
root_id=root_id,
flow_data=ticket_data,
pipeline=sub_pipeline,
iplist=exec_ips,
bk_cloud_id=ip_list[0]["bk_cloud_id"],
allow_empty_instance=True,
)

return sub_pipeline.build_sub_process(sub_name=_("MongoDB--cluster:{}容量变更".format(info["cluster_id"])))
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from backend.flow.consts import MongoDBClusterRole
from backend.flow.engine.bamboo.scene.common.builder import SubBuilder
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install import install_plugin
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install_dbmon import add_install_dbmon
from backend.flow.plugins.components.collections.mongodb.exec_actuator_job import ExecuteDBActuatorJobComponent
from backend.flow.plugins.components.collections.mongodb.mongodb_cmr_4_meta import CMRMongoDBMetaComponent
from backend.flow.plugins.components.collections.mongodb.send_media import ExecSendMediaOperationComponent
Expand Down Expand Up @@ -97,4 +98,17 @@ def shard_autofix(
sub_pipeline.add_act(
act_name=_("MongoDB-mongod修改meta"), act_component_code=CMRMongoDBMetaComponent.code, kwargs=kwargs
)

# 安装dbmon
ip_list = sub_get_kwargs.payload["plugin_hosts"]
exec_ips = [host["ip"] for host in ip_list]
add_install_dbmon(
root_id=root_id,
flow_data=ticket_data,
pipeline=sub_sub_pipeline,
iplist=exec_ips,
bk_cloud_id=ip_list[0]["bk_cloud_id"],
allow_empty_instance=True,
)

return sub_pipeline.build_sub_process(sub_name=_("MongoDB--{}自愈--ip:{}".format(name, info["ip"])))
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from backend.flow.engine.bamboo.scene.common.builder import SubBuilder
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install import install_plugin
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install_dbmon import add_install_dbmon
from backend.flow.plugins.components.collections.mongodb.add_domain_to_dns import ExecAddDomainToDnsOperationComponent
from backend.flow.plugins.components.collections.mongodb.exec_actuator_job import ExecuteDBActuatorJobComponent
from backend.flow.plugins.components.collections.mongodb.mongos_scale_4_meta import MongosScaleMetaComponent
Expand Down Expand Up @@ -110,4 +111,16 @@ def increase_mongos(root_id: str, ticket_data: Optional[Dict], sub_kwargs: ActKw
kwargs=kwargs,
)

# 安装dbmon
ip_list = sub_get_kwargs.payload["plugin_hosts"]
exec_ips = [host["ip"] for host in ip_list]
add_install_dbmon(
root_id=root_id,
flow_data=ticket_data,
pipeline=sub_pipeline,
iplist=exec_ips,
bk_cloud_id=ip_list[0]["bk_cloud_id"],
allow_empty_instance=True,
)

return sub_pipeline.build_sub_process(sub_name=_("MongoDB--{}增加mongos".format(cluster_name)))
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from backend.flow.consts import MongoDBClusterRole
from backend.flow.engine.bamboo.scene.common.builder import SubBuilder
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install import install_plugin
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install_dbmon import add_install_dbmon
from backend.flow.plugins.components.collections.mongodb.exec_actuator_job import ExecuteDBActuatorJobComponent
from backend.flow.plugins.components.collections.mongodb.mongodb_cmr_4_meta import CMRMongoDBMetaComponent
from backend.flow.plugins.components.collections.mongodb.send_media import ExecSendMediaOperationComponent
Expand Down Expand Up @@ -93,6 +94,17 @@ def replicaset_replace(
act_component_code=CMRMongoDBMetaComponent.code,
kwargs=kwargs,
)
# 安装dbmon 副本集
ip_list = sub_get_kwargs.payload["plugin_hosts"]
exec_ips = [host["ip"] for host in ip_list]
add_install_dbmon(
root_id=root_id,
flow_data=ticket_data,
pipeline=sub_pipeline,
iplist=exec_ips,
bk_cloud_id=ip_list[0]["bk_cloud_id"],
allow_empty_instance=True,
)
else:
if cluster_role == MongoDBClusterRole.ShardSvr.value:
info["db_type"] = "cluster_mongodb"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from backend.flow.consts import MongoDBClusterRole
from backend.flow.engine.bamboo.scene.common.builder import SubBuilder
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install import install_plugin
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install_dbmon import add_install_dbmon
from backend.flow.plugins.components.collections.mongodb.exec_actuator_job import ExecuteDBActuatorJobComponent
from backend.flow.plugins.components.collections.mongodb.send_media import ExecSendMediaOperationComponent
from backend.flow.utils.mongodb.mongodb_dataclass import ActKwargs
Expand Down Expand Up @@ -90,6 +91,17 @@ def replicaset_scale(

if not cluster_role:
name = "replicaset"
# 安装dbmon
ip_list = sub_get_kwargs.payload["plugin_hosts"]
exec_ips = [host["ip"] for host in ip_list]
add_install_dbmon(
root_id=root_id,
flow_data=ticket_data,
pipeline=sub_pipeline,
iplist=exec_ips,
bk_cloud_id=ip_list[0]["bk_cloud_id"],
allow_empty_instance=True,
)
else:
if cluster_role == MongoDBClusterRole.ShardSvr.value:
name = "shard"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from backend.flow.engine.bamboo.scene.common.builder import SubBuilder
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install import install_plugin
from backend.flow.engine.bamboo.scene.mongodb.mongodb_install_dbmon import add_install_dbmon
from backend.flow.plugins.components.collections.mongodb.exec_actuator_job import ExecuteDBActuatorJobComponent
from backend.flow.plugins.components.collections.mongodb.send_media import ExecSendMediaOperationComponent
from backend.flow.utils.mongodb.mongodb_dataclass import ActKwargs
Expand Down Expand Up @@ -83,4 +84,16 @@ def replicaset_set_increase_node(
sub_sub_pipelines.append(sub_sub_pipeline)
sub_pipeline.add_parallel_sub_pipeline(sub_flow_list=sub_sub_pipelines)

# 安装dbmon 副本集
ip_list = sub_get_kwargs.payload["plugin_hosts"]
exec_ips = [host["ip"] for host in ip_list]
add_install_dbmon(
root_id=root_id,
flow_data=ticket_data,
pipeline=sub_pipeline,
iplist=exec_ips,
bk_cloud_id=ip_list[0]["bk_cloud_id"],
allow_empty_instance=True,
)

return sub_pipeline.build_sub_process(sub_name=_("MongoDB--{}增加node".format("replicaset")))

0 comments on commit d5fb4e1

Please sign in to comment.