Skip to content

Commit

Permalink
fix(dbm-services): slave add domain 不需要做唯一性检查 #7870
Browse files Browse the repository at this point in the history
  • Loading branch information
ymakedaq authored and iSecloud committed Nov 12, 2024
1 parent cb1bfc7 commit 67a834e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions dbm-ui/backend/db_services/mysql/toolbox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,16 @@ def slave_ins_add_domain(self, request, **kwargs):
domain = data["domain_name"]
slave_ip = data["slave_ip"]
slave_port = data["slave_port"]
if ClusterEntry.objects.filter(cluster_entry_type=ClusterEntryType.DNS.value, entry=domain).exists():
return Response({"result": False, "message": _("{}域名已经存在".format(domain))})
cluster_obj = Cluster.objects.get(id=cluster_id)
cluster_entry = ClusterEntry.objects.create(
cluster=cluster_obj,
cluster_entry_type=ClusterEntryType.DNS.value,
entry=domain,
role=ClusterEntryRole.SLAVE_ENTRY.value,
)
if ClusterEntry.objects.filter(cluster_entry_type=ClusterEntryType.DNS.value, entry=domain).exists():
cluster_entry = ClusterEntry.objects.get(cluster_id=cluster_id, entry=domain)
else:
cluster_entry = ClusterEntry.objects.create(
cluster=cluster_obj,
cluster_entry_type=ClusterEntryType.DNS.value,
entry=domain,
role=ClusterEntryRole.SLAVE_ENTRY.value,
)
dns_manage = DnsManage(bk_biz_id=cluster_obj.bk_biz_id, bk_cloud_id=cluster_obj.bk_cloud_id)
slave_ins = cluster_obj.storageinstance_set.filter(
instance_inner_role=InstanceInnerRole.SLAVE.value, machine__ip=slave_ip, port=slave_port
Expand Down

0 comments on commit 67a834e

Please sign in to comment.