diff --git a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/api/esb/v3/EsbGetStepInstanceStatusV3ResourceImpl.java b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/api/esb/v3/EsbGetStepInstanceStatusV3ResourceImpl.java index c79ec4e532..4820a7bbc5 100644 --- a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/api/esb/v3/EsbGetStepInstanceStatusV3ResourceImpl.java +++ b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/api/esb/v3/EsbGetStepInstanceStatusV3ResourceImpl.java @@ -143,6 +143,7 @@ public EsbResp getStepInstanceStatus(String username .logKeyword(keyword) .searchIp(searchIp) .maxAgentTasksForResultGroup(maxHostNumPerGroup) + .fetchAllGroupData(status == null) .build(); StepExecutionDetailDTO executionResult = taskResultService.getStepExecutionResult(username, appId, query); diff --git a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/model/StepExecutionResultQuery.java b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/model/StepExecutionResultQuery.java index b25d8758cd..fbb85b9846 100644 --- a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/model/StepExecutionResultQuery.java +++ b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/model/StepExecutionResultQuery.java @@ -89,6 +89,10 @@ public class StepExecutionResultQuery { * 执行结果分组下返回的最大任务数 */ private Integer maxAgentTasksForResultGroup; + /** + * 是否获取所有分组下的所有主机执行数据(默认为false,只获取第一个分组中的数据) + */ + private boolean fetchAllGroupData; /** * 排序字段 */ 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 7bd9135bf4..ff890ec73c 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 @@ -322,10 +322,11 @@ private void setAgentTasksForAnyResultType(List resultG StepInstanceBaseDTO stepInstance, int executeCount, Integer batch, - Integer maxAgentTasksForResultGroup) { + Integer maxAgentTasksForResultGroup, + boolean fetchAllGroupData) { boolean isAgentTaskSet = false; for (AgentTaskResultGroupDTO resultGroup : resultGroups) { - if (!isAgentTaskSet) { + if (!isAgentTaskSet || fetchAllGroupData) { isAgentTaskSet = fillAgentTasksForResultGroup(resultGroup, stepInstance, executeCount, batch, resultGroup.getStatus(), resultGroup.getTag(), maxAgentTasksForResultGroup); } else { @@ -533,7 +534,9 @@ private StepExecutionDetailDTO loadAllTasksFromDBAndBuildExecutionResultInMemory filterAgentTasksByMatchIp(resultGroups, query.getMatchHostIds()); } - removeAgentTasksForNotSpecifiedResultGroup(resultGroups, query.getStatus(), query.getTag()); + if (!query.isFetchAllGroupData()) { + removeAgentTasksForNotSpecifiedResultGroup(resultGroups, query.getStatus(), query.getTag()); + } watch.stop(); @@ -725,11 +728,11 @@ private StepExecutionDetailDTO filterAndSortExecutionResultInDB(StopWatch watch, setAgentTasksForSpecifiedResultType(resultGroups, status, tag, tasks); } else { setAgentTasksForAnyResultType(resultGroups, stepInstance, queryExecuteCount, - query.getBatch(), query.getMaxAgentTasksForResultGroup()); + query.getBatch(), query.getMaxAgentTasksForResultGroup(), query.isFetchAllGroupData()); } } else { setAgentTasksForAnyResultType(resultGroups, stepInstance, queryExecuteCount, - query.getBatch(), query.getMaxAgentTasksForResultGroup()); + query.getBatch(), query.getMaxAgentTasksForResultGroup(), query.isFetchAllGroupData()); } watch.stop();