From ffd49a7ab798d5296f7bcf6528d8a0a7e1785341 Mon Sep 17 00:00:00 2001 From: xcwang <1366993017@qq.com> Date: Mon, 18 Jul 2022 10:34:07 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E9=83=A8=E7=BD=B2=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E8=A2=AB=E6=8A=91=E5=88=B6=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=B8=BB=E6=8A=91=E5=88=B6=E7=AD=96=E7=95=A5=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=B6=85=E9=93=BE=E6=8E=A5=20(closed=20#889)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/backend/subscription/tasks.py | 11 ++++---- apps/node_man/handlers/job.py | 37 +++++++++++++------------ dev_log/2.2.22/xcwang_202209071547.yaml | 3 ++ 3 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 dev_log/2.2.22/xcwang_202209071547.yaml diff --git a/apps/backend/subscription/tasks.py b/apps/backend/subscription/tasks.py index aea794fcb..ec518948e 100644 --- a/apps/backend/subscription/tasks.py +++ b/apps/backend/subscription/tasks.py @@ -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"), @@ -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( @@ -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], diff --git a/apps/node_man/handlers/job.py b/apps/node_man/handlers/job.py index 9857af63e..ae5fdf33c 100644 --- a/apps/node_man/handlers/job.py +++ b/apps/node_man/handlers/job.py @@ -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) # 补充业务名、云区域名称 diff --git a/dev_log/2.2.22/xcwang_202209071547.yaml b/dev_log/2.2.22/xcwang_202209071547.yaml new file mode 100644 index 000000000..b7c613e75 --- /dev/null +++ b/dev_log/2.2.22/xcwang_202209071547.yaml @@ -0,0 +1,3 @@ +--- +feature: + - "部署策略执行被抑制时,主抑制策略增加超链接 (closed #889)"