From e5b568106374cf72be8c9b4f692c8ef5931d1a6c Mon Sep 17 00:00:00 2001 From: yunchao Date: Fri, 22 Mar 2024 11:57:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=89=E8=A3=85=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0force=5Fupdate=5Fagent=5Fid=E5=8F=82=E6=95=B0?= =?UTF-8?q?=20(closed=20#2132)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/backend/agent/solution_maker.py | 2 +- .../components/collections/agent_new/install_other_agent.py | 2 ++ apps/node_man/serializers/job.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/backend/agent/solution_maker.py b/apps/backend/agent/solution_maker.py index 9a1d1520e..1bc8a21fe 100644 --- a/apps/backend/agent/solution_maker.py +++ b/apps/backend/agent/solution_maker.py @@ -298,7 +298,7 @@ def get_run_cmd_base_params(self) -> typing.List[str]: # 因 bat 脚本逻辑,-R 参数只能放在最后一位 if self.is_uninstall: run_cmd_params.extend(["-R"]) - if self.agent_setup_info.force_update_agent_id: + if not self.agent_setup_info.is_legacy and self.agent_setup_info.force_update_agent_id: run_cmd_params.extend(["-F"]) return list(filter(None, run_cmd_params)) diff --git a/apps/backend/components/collections/agent_new/install_other_agent.py b/apps/backend/components/collections/agent_new/install_other_agent.py index 1d1a91ab3..f1646c91b 100644 --- a/apps/backend/components/collections/agent_new/install_other_agent.py +++ b/apps/backend/components/collections/agent_new/install_other_agent.py @@ -96,6 +96,7 @@ def _execute(self, data, parent_data, common_data: AgentCommonData): # AP_ID 偏移规则 ap_id * 100000 + install_channel_id offset_ap_id = ap_id * INSTALL_OTHER_AGENT_AP_ID_OFFSET + (host.install_channel_id or 0) + agent_setup_extra_info_dict = sub_inst.instance_info["host"].get("agent_setup_extra_info") or {} host_info: Dict[str, Any] = { "bk_host_id": host.bk_host_id, "os_type": host.os_type, @@ -112,6 +113,7 @@ def _execute(self, data, parent_data, common_data: AgentCommonData): "install_channel_id": host.install_channel_id, "peer_exchange_switch_for_agent": host.extra_data.get("peer_exchange_switch_for_agent", 0), "enable_compression": host.extra_data.get("enable_compression", False), + "force_update_agent_id": agent_setup_extra_info_dict.get("force_update_agent_id", False), } hosts.append(host_info) diff --git a/apps/node_man/serializers/job.py b/apps/node_man/serializers/job.py index 1985fe825..0287e12ba 100644 --- a/apps/node_man/serializers/job.py +++ b/apps/node_man/serializers/job.py @@ -191,6 +191,7 @@ class HostSerializer(InstallBaseSerializer): is_need_inject_ap_id = serializers.BooleanField(label=_("是否需要注入ap_id到meta"), required=False, default=False) enable_compression = serializers.BooleanField(label=_("数据压缩开关"), required=False, default=False) is_use_ap_map = serializers.BooleanField(label=_("是否使用映射接入点"), required=False, default=False) + force_update_agent_id = serializers.BooleanField(label=_("是否更新agent_id"), required=False, default=False) def validate(self, attrs): # 获取任务类型,如果是除安装以外的操作,则密码和秘钥可以为空