From f6e6ac5958825170cbc3ab1fec3125460f5e8754 Mon Sep 17 00:00:00 2001 From: dcd <1151627903@qq.com> Date: Tue, 14 May 2024 15:29:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=89=E8=A3=85P-Agent=E6=9C=AA?= =?UTF-8?q?=E5=9C=A8=E9=9D=9E=E5=85=A8=E4=B8=9A=E5=8A=A1=E9=9B=86=E4=B8=8B?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=20(closed=20#2233)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/collections/agent_new/install.py | 13 ++++++++----- .../collections/plugin/test_transfer_script.py | 1 - 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/backend/components/collections/agent_new/install.py b/apps/backend/components/collections/agent_new/install.py index d9af29d3a..227f38cce 100644 --- a/apps/backend/components/collections/agent_new/install.py +++ b/apps/backend/components/collections/agent_new/install.py @@ -168,12 +168,13 @@ def outputs_format(self): get_config_dict_func=core.get_config_dict, get_config_dict_kwargs={"config_name": core.ServiceCCConfigName.JOB_CMD.value}, ) - def handle_non_lan_inst(self, install_sub_inst_objs: List[InstallSubInstObj]) -> List[int]: + def handle_non_lan_inst(self, install_sub_inst_objs: List[InstallSubInstObj], bk_biz_id: int) -> List[int]: """处理跨云机器,通过执行作业平台脚本来操作""" params_list = [ { "sub_inst_id": install_sub_inst_obj.sub_inst_id, "installation_tool": install_sub_inst_obj.installation_tool, + "bk_biz_id": bk_biz_id, } for install_sub_inst_obj in install_sub_inst_objs ] @@ -378,7 +379,11 @@ def _execute(self, data, parent_data, common_data: base.AgentCommonData): remote_conn_helpers_gby_result_type = self.bulk_check_ssh(remote_conn_helpers=lan_windows_sub_inst) if non_lan_sub_inst: - succeed_non_lan_inst_ids = self.handle_non_lan_inst(install_sub_inst_objs=non_lan_sub_inst) + job_meta: Dict[str, Any] = self.get_job_meta(data) + bk_biz_id: int = job_meta["bk_biz_id"] + succeed_non_lan_inst_ids = self.handle_non_lan_inst( + install_sub_inst_objs=non_lan_sub_inst, bk_biz_id=bk_biz_id + ) else: succeed_non_lan_inst_ids = [] @@ -533,7 +538,7 @@ def push_curl_exe( # 不统计异常耗时 include_exception_histogram=False, ) - def execute_job_commands(self, sub_inst_id, installation_tool: InstallationTools): + def execute_job_commands(self, sub_inst_id, installation_tool: InstallationTools, bk_biz_id: int): # p-agent 走 作业平台,再 ssh 到 p-agent,这样可以无需保存 proxy 密码 host = installation_tool.host jump_server = installation_tool.jump_server @@ -546,8 +551,6 @@ def execute_job_commands(self, sub_inst_id, installation_tool: InstallationTools log_content=_("已选择 {inner_ip} 作为本次安装的跳板机").format(inner_ip=jump_server.inner_ip or jump_server.inner_ipv6), ) - # 使用全业务执行作业 - bk_biz_id = settings.BLUEKING_BIZ_ID target_server: Dict[str, List[Union[int, Dict[str, Union[int, str]]]]] = ( {"host_id_list": [jump_server.bk_host_id]} if settings.BKAPP_ENABLE_DHCP diff --git a/apps/backend/tests/components/collections/plugin/test_transfer_script.py b/apps/backend/tests/components/collections/plugin/test_transfer_script.py index c7b57674b..a75d511c0 100644 --- a/apps/backend/tests/components/collections/plugin/test_transfer_script.py +++ b/apps/backend/tests/components/collections/plugin/test_transfer_script.py @@ -116,7 +116,6 @@ def test_component(self): "job_instance_id": JOB_INSTANCE_ID, } super().test_component() - print(fast_transfer_file.call_args) self.assertEqual( 10, fast_transfer_file.call_args[0][0]["bk_biz_id"],