Skip to content

Commit

Permalink
feature: 部署策略执行被抑制时,主抑制策略增加超链接 (closed TencentBlueKing#889)
Browse files Browse the repository at this point in the history
  • Loading branch information
CohleRustW committed Sep 7, 2022
1 parent 4d74142 commit ffd49a7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
11 changes: 6 additions & 5 deletions apps/backend/subscription/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ def create_task(
is_suppressed = result["is_suppressed"]
if is_suppressed:
# 策略被抑制,跳过部署,记为已忽略
suppressed_by_id: int = result["suppressed_by"]["subscription_id"]
suppressed_by_name: str = result["suppressed_by"]["name"]
error_hosts.append(
{
"ip": host_info.get("bk_host_innerip") or host_info.get("bk_host_innerip_v6"),
Expand All @@ -321,14 +323,13 @@ def create_task(
"bk_host_id": host_info.get("bk_host_id"),
"bk_biz_id": host_info.get("bk_biz_id"),
"bk_cloud_id": host_info.get("bk_cloud_id"),
"suppressed_by_id": result["suppressed_by"]["subscription_id"],
"suppressed_by_name": result["suppressed_by"]["name"],
"suppressed_by_id": suppressed_by_id,
"suppressed_by_name": suppressed_by_name,
"os_type": node_man_tools.HostV2Tools.get_os_type(host_info),
"status": constants.JobStatusType.IGNORED,
"msg": _(
"当前{category_alias}({bk_obj_name} 级)"
"已被优先级更高的{suppressed_by_category_alias}【{suppressed_by_name}(ID: {suppressed_by_id})】"
"({suppressed_by_obj_name} 级)抑制"
).format(
category_alias=models.Subscription.CATEGORY_ALIAS_MAP[result["category"]],
bk_obj_name=constants.CmdbObjectId.OBJ_ID_ALIAS_MAP.get(
Expand All @@ -338,8 +339,8 @@ def create_task(
suppressed_by_category_alias=models.Subscription.CATEGORY_ALIAS_MAP[
result["suppressed_by"]["category"]
],
suppressed_by_name=result["suppressed_by"]["name"],
suppressed_by_id=result["suppressed_by"]["subscription_id"],
suppressed_by_name=suppressed_by_name,
suppressed_by_id=suppressed_by_id,
suppressed_by_obj_name=constants.CmdbObjectId.OBJ_ID_ALIAS_MAP.get(
result["suppressed_by"]["bk_obj_id"],
constants.CmdbObjectId.OBJ_ID_ALIAS_MAP[constants.CmdbObjectId.CUSTOM],
Expand Down
37 changes: 20 additions & 17 deletions apps/node_man/handlers/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,23 +786,26 @@ def retrieve(self, params: Dict[str, Any]):
# conditions中无status或者筛选条件为空列表 视为全选,过滤不在筛选条件中的排除主机
if statuses_in_conditions and status not in statuses_in_conditions:
continue
filter_hosts.append(
{
"filter_host": True,
"bk_host_id": host.get("bk_host_id"),
"ip": host["ip"],
"inner_ip": host.get("inner_ip"),
"inner_ipv6": host.get("inner_ipv6"),
"bk_cloud_id": host.get("bk_cloud_id"),
"bk_cloud_name": host.get("bk_cloud_name"),
"bk_biz_id": host.get("bk_biz_id"),
"bk_biz_name": host.get("bk_biz_name"),
"job_id": host.get("job_id"),
"status": host.get("status") or constants.JobStatusType.FAILED,
"status_display": host.get("msg"),
"step": "",
}
)

filter_host_info: Dict[str, Union[bool, str, int]] = {
"filter_host": True,
"bk_host_id": host.get("bk_host_id"),
"ip": host["ip"],
"inner_ip": host.get("inner_ip"),
"inner_ipv6": host.get("inner_ipv6"),
"bk_cloud_id": host.get("bk_cloud_id"),
"bk_cloud_name": host.get("bk_cloud_name"),
"bk_biz_id": host.get("bk_biz_id"),
"bk_biz_name": host.get("bk_biz_name"),
"job_id": host.get("job_id"),
"status": host.get("status") or constants.JobStatusType.FAILED,
"status_display": host.get("msg"),
"step": "",
}
host_suppressed_by_id = host.get("suppressed_by_id", None)
if host_suppressed_by_id is not None:
filter_host_info.update({"suppressed_by_id": host_suppressed_by_id})
filter_hosts.append(filter_host_info)
host_execute_status_list.extend(filter_hosts)

# 补充业务名、云区域名称
Expand Down
3 changes: 3 additions & 0 deletions dev_log/2.2.22/xcwang_202209071547.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
feature:
- "部署策略执行被抑制时,主抑制策略增加超链接 (closed #889)"

0 comments on commit ffd49a7

Please sign in to comment.