Skip to content

Commit

Permalink
fix: 容器执行灰度判断错误,导致主机执行的任务报错 TencentBlueKing#2978
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 committed May 14, 2024
1 parent c542415 commit 647fa40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,6 @@ public class ExecuteTargetDTO implements Cloneable {
*/
private List<ExecuteObject> executeObjects;

public static ExecuteTargetDTO emptyInstance() {
ExecuteTargetDTO executeTargetDTO = new ExecuteTargetDTO();
executeTargetDTO.setIpList(Collections.emptyList());
executeTargetDTO.setDynamicServerGroups(Collections.emptyList());
executeTargetDTO.setStaticIpList(Collections.emptyList());
executeTargetDTO.setTopoNodes(Collections.emptyList());
executeTargetDTO.setStaticContainerList(Collections.emptyList());
return executeTargetDTO;
}

public ExecuteTargetDTO clone() {
ExecuteTargetDTO clone = new ExecuteTargetDTO();
clone.setVariable(variable);
Expand Down Expand Up @@ -617,6 +607,6 @@ private static List<KubeContainerFilter> convertToKubeContainerFilter(OpenApiExe
* 执行目标中是否包含容器执行对象
*/
public boolean hasContainerExecuteObject() {
return staticContainerList != null || containerFilters != null;
return CollectionUtils.isNotEmpty(staticContainerList) || CollectionUtils.isNotEmpty(containerFilters);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1088,8 +1088,12 @@ username, new AppResourceScope(appId), plan.getTaskTemplateId(),
whiteHostAllowActions);
authServers.merge(stepTargetServers);
if (!CollectionUtils.isEmpty(stepInstance.getFileSourceList())) {
stepInstance.getFileSourceList().stream().filter(fileSource -> !fileSource.isLocalUpload())
stepInstance.getFileSourceList().stream()
.filter(fileSource -> !fileSource.isLocalUpload())
.forEach(fileSource -> {
if (fileSource.getServers() == null) {
return;
}
ExecuteTargetDTO stepFileSourceServers = fileSource.getServers().clone();
filterHostsDoNotRequireAuth(ActionScopeEnum.FILE_DISTRIBUTION, stepFileSourceServers,
whiteHostAllowActions);
Expand Down Expand Up @@ -1500,7 +1504,6 @@ private void parseFileStepInstanceFromPlanStep(StepInstanceDTO stepInstance, Ser
fileSource.setFiles(fileList);
} else if (originFile.getFileType() == TaskFileTypeEnum.FILE_SOURCE.getType()) {
fileSource.setLocalUpload(false);
fileSource.setServers(ExecuteTargetDTO.emptyInstance());
// 文件源文件只需要fileSourceId与文件路径
List<FileDetailDTO> fileList = new ArrayList<>();
originFile.getFileLocation().forEach(fileLocation -> fileList.add(new FileDetailDTO(fileLocation)));
Expand Down

0 comments on commit 647fa40

Please sign in to comment.