Skip to content

Commit

Permalink
fix: 安装P-Agent未在非全业务集下执行 (closed TencentBlueKing#2233)
Browse files Browse the repository at this point in the history
  • Loading branch information
Huayeaaa committed May 20, 2024
1 parent 853ad5e commit f6e6ac5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 8 additions & 5 deletions apps/backend/components/collections/agent_new/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down Expand Up @@ -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 = []

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down

0 comments on commit f6e6ac5

Please sign in to comment.