From cf799565d1e39e64074fac7530c9ad34cdd3fa9e Mon Sep 17 00:00:00 2001 From: wangyu096 Date: Tue, 2 Jan 2024 12:03:03 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20Job=20=E6=94=AF=E6=8C=81=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E6=89=A7=E8=A1=8C=20-=20=E8=84=9A=E6=9C=AC=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=20#2631?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/WebTaskExecutionResultResource.java | 4 +--- .../WebTaskExecutionResultResourceImpl.java | 1 - .../FileExecuteObjectTaskServiceImpl.java | 3 ++- .../service/impl/TaskExecuteServiceImpl.java | 20 ++++++++++--------- .../service/impl/TaskResultServiceImpl.java | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/backend/job-execute/api-job-execute/src/main/java/com/tencent/bk/job/execute/api/web/WebTaskExecutionResultResource.java b/src/backend/job-execute/api-job-execute/src/main/java/com/tencent/bk/job/execute/api/web/WebTaskExecutionResultResource.java index bc85a29d30..e2c497b6fb 100644 --- a/src/backend/job-execute/api-job-execute/src/main/java/com/tencent/bk/job/execute/api/web/WebTaskExecutionResultResource.java +++ b/src/backend/job-execute/api-job-execute/src/main/java/com/tencent/bk/job/execute/api/web/WebTaskExecutionResultResource.java @@ -342,9 +342,7 @@ Response getFileLogContentByHost( @ApiParam(value = "执行次数,首次传0", name = "executeCount", required = true) @PathVariable("executeCount") Integer executeCount, - @ApiParam(value = "主机ip(云区域ID:ip),兼容历史版本数据,后续会删除;建议使用hostId", name = "ip") - @PathVariable(value = "ip", required = false) String ip, - @ApiParam(value = "主机ID,优先级比ip参数高", name = "hostId") + @ApiParam(value = "主机ID", name = "hostId") @PathVariable(value = "hostId", required = false) Long hostId, @ApiParam(value = "文件任务上传下载标识,upload-上传,download-下载", name = "mode", required = true) @RequestParam(value = "mode") diff --git a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/api/web/impl/WebTaskExecutionResultResourceImpl.java b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/api/web/impl/WebTaskExecutionResultResourceImpl.java index b36cc048e4..658d286ca6 100644 --- a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/api/web/impl/WebTaskExecutionResultResourceImpl.java +++ b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/api/web/impl/WebTaskExecutionResultResourceImpl.java @@ -852,7 +852,6 @@ public Response getFileLogContentByHost(String username, String scopeId, Long stepInstanceId, Integer executeCount, - String ip, Long hostId, String mode, Integer batch) { diff --git a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/service/impl/FileExecuteObjectTaskServiceImpl.java b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/service/impl/FileExecuteObjectTaskServiceImpl.java index c7bb0c54b6..c6aa0d8c16 100644 --- a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/service/impl/FileExecuteObjectTaskServiceImpl.java +++ b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/service/impl/FileExecuteObjectTaskServiceImpl.java @@ -130,7 +130,8 @@ public List listAndGroupTasks(StepInstanceBaseDTO stepInstance, int executeCount, Integer batch) { List resultGroups = new ArrayList<>(); - List executeObjectTasks = listTasks(stepInstance, executeCount, batch); + List executeObjectTasks = listTasks(stepInstance, executeCount, + batch, FileTaskModeEnum.DOWNLOAD); if (CollectionUtils.isEmpty(executeObjectTasks)) { return resultGroups; } diff --git a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/service/impl/TaskExecuteServiceImpl.java b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/service/impl/TaskExecuteServiceImpl.java index 73451c3e47..0829c88cfc 100644 --- a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/service/impl/TaskExecuteServiceImpl.java +++ b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/service/impl/TaskExecuteServiceImpl.java @@ -381,10 +381,12 @@ private boolean isSupportExecuteObjectFeature(TaskInstanceDTO taskInstance) { .addContextParam(ToggleStrategyContextParams.CTX_PARAM_RESOURCE_SCOPE, appScopeMappingService.getScopeByAppId(taskInstance.getAppId())); - return FeatureToggle.checkFeature( + boolean featureEnabled = FeatureToggle.checkFeature( FeatureIdConstants.FEATURE_EXECUTE_OBJECT, featureExecutionContext ); + log.info("Check feature: {}, result: {}", FeatureIdConstants.FEATURE_EXECUTE_OBJECT, featureEnabled); + return featureEnabled; } private void saveTaskInstance(StopWatch watch, @@ -849,7 +851,7 @@ private void fillTaskInstanceContainerDetail(TaskInstanceExecuteObjects taskInst taskInstanceExecuteObjects.setNotExistContainerIds(notExistContainerIds); for (StepInstanceDTO stepInstance : stepInstanceList) { - if (!isStepContainsExecuteObject(stepInstance)) { + if (isStepDoNotContainsExecuteObject(stepInstance)) { continue; } if (CollectionUtils.isNotEmpty(stepInstance.getTargetExecuteObjects().getStaticContainerList())) { @@ -1042,7 +1044,7 @@ private void checkExecuteObjectAccessible(List stepInstanceList // 非法的主机 Set invalidHosts = new HashSet<>(); for (StepInstanceDTO stepInstance : stepInstanceList) { - if (!isStepContainsExecuteObject(stepInstance)) { + if (isStepDoNotContainsExecuteObject(stepInstance)) { continue; } TaskStepTypeEnum stepType = stepInstance.getStepType(); @@ -1185,7 +1187,7 @@ private void setHostsForTopoNode(ExecuteObjectsDTO servers, } private void checkStepInstanceHostNonEmpty(StepInstanceDTO stepInstance) { - if (!isStepContainsExecuteObject(stepInstance)) { + if (isStepDoNotContainsExecuteObject(stepInstance)) { return; } ExecuteObjectsDTO targetExecuteObjects = stepInstance.getTargetExecuteObjects(); @@ -1211,9 +1213,9 @@ private void checkStepInstanceHostNonEmpty(StepInstanceDTO stepInstance) { } } - private boolean isStepContainsExecuteObject(StepInstanceBaseDTO stepInstance) { + private boolean isStepDoNotContainsExecuteObject(StepInstanceBaseDTO stepInstance) { // 判断步骤是否包含执行对象 - return stepInstance.isScriptStep() || stepInstance.isFileStep(); + return !stepInstance.isScriptStep() && !stepInstance.isFileStep(); } private void fillTaskInstanceHostDetail(TaskInstanceDTO taskInstance, @@ -1238,7 +1240,7 @@ private void fillTaskInstanceHostDetail(TaskInstanceDTO taskInstance, } for (StepInstanceDTO stepInstance : stepInstanceList) { - if (!isStepContainsExecuteObject(stepInstance)) { + if (isStepDoNotContainsExecuteObject(stepInstance)) { continue; } // 目标主机设置主机详情 @@ -1341,7 +1343,7 @@ private Set extractHosts(List stepInstanceList, Collection variables) { Set hosts = new HashSet<>(); for (StepInstanceDTO stepInstance : stepInstanceList) { - if (!isStepContainsExecuteObject(stepInstance)) { + if (isStepDoNotContainsExecuteObject(stepInstance)) { continue; } if (stepInstance.getTargetExecuteObjects() != null) { @@ -1426,7 +1428,7 @@ private void checkStepInstanceAtomicTasksLimit(TaskInstanceDTO taskInstance, int sourceServerSize = 1; Integer fileType = fileSource.getFileType(); if (fileType == TaskFileTypeEnum.SERVER.getType() && fileSource.getServers() != null) { - sourceServerSize = CollectionUtils.size(fileSource.getServers().getIpList()); + sourceServerSize = CollectionUtils.size(fileSource.getServers().getExecuteObjectsCompatibly()); } int sourceFileSize = CollectionUtils.size(fileSource.getFiles()); totalSourceFileSize += sourceServerSize * sourceFileSize; diff --git a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/service/impl/TaskResultServiceImpl.java b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/service/impl/TaskResultServiceImpl.java index 64076c8ab2..437f577db2 100644 --- a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/service/impl/TaskResultServiceImpl.java +++ b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/service/impl/TaskResultServiceImpl.java @@ -717,7 +717,7 @@ private StepExecutionDetailDTO filterAndSortExecutionResultInDB(StopWatch watch, queryExecuteCount, query.getBatch()); watch.stop(); - watch.start("setAgentTasks"); + watch.start("setExecuteObjectTasks"); List resultGroups = baseResultGroups.stream() .map(ResultGroupDTO::new) .collect(Collectors.toList());