Skip to content

Commit

Permalink
fix(backend): sqlserver批量部署集群问题 #8681
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 27114
  • Loading branch information
ygcyao authored and iSecloud committed Dec 18, 2024
1 parent cbac0cb commit 1c5e39e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions dbm-ui/backend/ticket/builders/sqlserver/sqlserver_ha_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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"][MachineType.SQLSERVER_HA.value]["count"]
machine_count = attrs["resource_spec"]["backend_group"]["count"] * 2
else:
machine_count = len(attrs["nodes"][MachineType.SQLSERVER_HA.value])
if machine_count != expected_count:
Expand Down Expand Up @@ -85,12 +85,12 @@ 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"][MachineType.SQLSERVER_HA.value]
backend_nodes = ticket_data["nodes"]["backend_group"]
for index, apply_info in enumerate(infos):
# 每组集群需要两个后端 IP 和两个 Proxy IP
start, end = index * 2, (index + 1) * 2
apply_info["mssql_master_host"] = backend_nodes[start:end][0]
apply_info["mssql_slave_host"] = backend_nodes[start:end][1]
# # 每组集群需要两个后端 IP 和两个 Proxy IP
# start, end = index * 2, (index + 1) * 2
apply_info["mssql_master_host"] = backend_nodes[index]["master"]
apply_info["mssql_slave_host"] = backend_nodes[index]["slave"]


class SQLServerHaApplyResourceParamBuilder(SQLServerSingleApplyResourceParamBuilder):
Expand All @@ -101,6 +101,9 @@ def post_callback(self):
next_flow = self.ticket.next_flow()
infos = next_flow.details["ticket_data"]["infos"]
SQLServerHAApplyFlowParamBuilder.insert_ip_into_apply_infos(self.ticket.details, infos)
next_flow.details["ticket_data"]["resource_spec"]["sqlserver_ha"] = next_flow.details["ticket_data"][
"resource_spec"
]["master"]
next_flow.details["ticket_data"].update(infos=infos)
next_flow.save(update_fields=["details"])

Expand Down

0 comments on commit 1c5e39e

Please sign in to comment.