Skip to content

Commit

Permalink
fix(backend): 资源申请同城同园区补充include_or_exclue参数 #9186
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 29771
  • Loading branch information
ygcyao authored and iSecloud committed Jan 22, 2025
1 parent 2d28eb4 commit d50a6da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
9 changes: 4 additions & 5 deletions dbm-ui/backend/ticket/builders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,16 @@ def patch_affinity_location(cls, cluster, resource_spec, roles=None):
节点变更的时候,补充亲和性和位置参数
"""
bk_sub_zone_id = None
# 同城同园区集群的园区id处理
# 资源申请同城同园区条件:补充园区id, 且需传include_or_exclude=True来指定申请的园区,如不传nclude_or_exclude参数,默认视为包含该园区
if cluster.disaster_tolerance_level in [AffinityEnum.SAME_SUBZONE, AffinityEnum.SAME_SUBZONE_CROSS_SWTICH]:
bk_sub_zone_id = cluster.storageinstance_set.first().machine.bk_sub_zone_id

resource_role = roles or resource_spec.keys()
for role in resource_role:
resource_spec[role]["affinity"] = cluster.disaster_tolerance_level
resource_spec[role]["location_spec"] = {
"city": cluster.region,
"sub_zone_ids": [bk_sub_zone_id] if bk_sub_zone_id else [],
}
resource_spec[role]["location_spec"] = {"city": cluster.region, "sub_zone_ids": []}
if bk_sub_zone_id:
resource_spec[role]["location_spec"].update(sub_zone_ids=[bk_sub_zone_id], include_or_exclude=True)


class TicketFlowBuilder:
Expand Down
11 changes: 6 additions & 5 deletions dbm-ui/backend/ticket/builders/redis/redis_toolbox_cut_off.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def patch_ticket_detail(self):
continue

if role in [InstanceRole.REDIS_MASTER.value, InstanceRole.REDIS_PROXY.value]:
# 同城同园区集群的园区id处理
bk_sub_zone_id = None
if cluster.disaster_tolerance_level in [
AffinityEnum.SAME_SUBZONE,
Expand All @@ -132,12 +131,14 @@ def patch_ticket_detail(self):
resource_spec[resource_role] = {
"spec_id": info[role][0]["spec_id"],
"count": len(role_hosts),
"location_spec": {
"city": cluster.region,
"sub_zone_ids": [bk_sub_zone_id] if bk_sub_zone_id else [],
},
"location_spec": {"city": cluster.region, "sub_zone_ids": []},
"affinity": cluster.disaster_tolerance_level,
}
# 资源申请同城同园区条件:补充园区id, 且需传include_or_exclude=True来指定申请的园区,如不传nclude_or_exclude参数,默认视为包含该园区
if bk_sub_zone_id:
resource_spec[resource_role]["location_spec"].update(
sub_zone_ids=[bk_sub_zone_id], include_or_exclude=True
)
# 如果是proxy,则至少跨两个机房
if role == InstanceRole.REDIS_PROXY.value:
resource_spec[resource_role].update(group_count=2)
Expand Down

0 comments on commit d50a6da

Please sign in to comment.