Skip to content

Commit

Permalink
fix(backend): sqlserver 主从、单节点部署联调 #3859
Browse files Browse the repository at this point in the history
  • Loading branch information
ygcyao authored and zhangzhw8 committed Apr 10, 2024
1 parent f244e38 commit 66fb5f1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from backend.db_meta.enums import ClusterPhase
from backend.flow.engine.controller.sqlserver import SqlserverController
from backend.iam_app.dataclass.actions import ActionEnum
from backend.ticket import builders
from backend.ticket.builders.sqlserver.base import BaseSQLServerTicketFlowBuilder, SQLServerTakeDownDetailsSerializer
from backend.ticket.constants import FlowRetryType, TicketType
Expand All @@ -26,7 +27,9 @@ class SQLServerDisableFlowParamBuilder(builders.FlowParamBuilder):
controller = SqlserverController.cluster_disable_scene


@builders.BuilderFactory.register(TicketType.SQLSERVER_DISABLE, phase=ClusterPhase.OFFLINE)
@builders.BuilderFactory.register(
TicketType.SQLSERVER_DISABLE, phase=ClusterPhase.OFFLINE, iam=ActionEnum.SQLSERVER_ENABLE_DISABLE
)
class SQLServerDestroyFlowBuilder(BaseSQLServerTicketFlowBuilder):
"""Sqlserver禁用流程的构建基类"""

Expand Down
5 changes: 4 additions & 1 deletion dbm-ui/backend/ticket/builders/sqlserver/sqlserver_enable.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from backend.db_meta.enums import ClusterPhase
from backend.flow.engine.controller.sqlserver import SqlserverController
from backend.iam_app.dataclass.actions import ActionEnum
from backend.ticket import builders
from backend.ticket.builders.mysql.base import MySQLClustersTakeDownDetailsSerializer
from backend.ticket.builders.sqlserver.base import BaseSQLServerTicketFlowBuilder
Expand All @@ -27,7 +28,9 @@ class SQLServerEnableFlowParamBuilder(builders.FlowParamBuilder):
controller = SqlserverController.cluster_enable_scene


@builders.BuilderFactory.register(TicketType.SQLSERVER_ENABLE, phase=ClusterPhase.ONLINE)
@builders.BuilderFactory.register(
TicketType.SQLSERVER_ENABLE, phase=ClusterPhase.ONLINE, iam=ActionEnum.SQLSERVER_ENABLE_DISABLE
)
class SQLServerEnableFlowBuilder(BaseSQLServerTicketFlowBuilder):
"""Sqlserver启用流程的构建基类"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from rest_framework import serializers

from backend.configuration.constants import MASTER_DOMAIN_INITIAL_VALUE, SLAVE_DOMAIN_INITIAL_VALUE, AffinityEnum
from backend.db_meta.enums import ClusterType
from backend.db_meta.enums import ClusterType, MachineType
from backend.db_meta.models import DBModule
from backend.db_services.cmdb.biz import get_db_app_abbr
from backend.db_services.dbbase.constants import IpSource
Expand Down Expand Up @@ -47,7 +47,7 @@ def validate(self, attrs):
attrs["cluster_count"] // attrs["inst_num"] + bool(attrs["cluster_count"] % attrs["inst_num"])
)
if attrs["ip_source"] == IpSource.RESOURCE_POOL:
machine_count = attrs["resource_spec"]["backend"]["count"]
machine_count = attrs["resource_spec"][MachineType.SQLSERVER_HA.value]["count"]
else:
machine_count = len(attrs["nodes"]["backend"])
if machine_count != expected_count:
Expand Down Expand Up @@ -90,7 +90,7 @@ def format_cluster_domains(self) -> List[Dict[str, str]]:

@classmethod
def insert_ip_into_apply_infos(cls, ticket_data, infos: List[Dict]):
backend_nodes = ticket_data["nodes"]["backend"]
backend_nodes = ticket_data["nodes"][MachineType.SQLSERVER_HA.value]
for index, apply_info in enumerate(infos):
# 每组集群需要两个后端 IP 和两个 Proxy IP
start, end = index * 2, (index + 1) * 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from backend.bk_web.constants import LEN_MIDDLE, SMALLEST_POSITIVE_INTEGER
from backend.configuration.constants import MASTER_DOMAIN_INITIAL_VALUE
from backend.db_meta.enums import ClusterType
from backend.db_meta.enums import ClusterType, MachineType
from backend.db_meta.models import DBModule
from backend.db_services.cmdb.biz import get_db_app_abbr
from backend.db_services.dbbase.constants import IpSource
Expand Down Expand Up @@ -155,7 +155,7 @@ def format_cluster_domains(self) -> List[Dict[str, str]]:
@classmethod
def insert_ip_into_apply_infos(cls, ticket_data, infos: List[Dict]):
# 适配手动输入和资源池导入的角色类型
backend_nodes = ticket_data["nodes"]["backend"] or ticket_data["nodes"]["single"]
backend_nodes = ticket_data["nodes"][MachineType.SQLSERVER_SINGLE.value] or ticket_data["nodes"]["single"]
for index, apply_info in enumerate(infos):
apply_info["mssql_host"] = backend_nodes[index]

Expand Down

0 comments on commit 66fb5f1

Please sign in to comment.