Skip to content

Commit

Permalink
bugfix: 本地文件分发报错 TencentBlueKing#1592
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 committed Dec 8, 2022
1 parent ebc6a7e commit a044d5c
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.tencent.bk.job.execute.config.StorageSystemConfig;
import com.tencent.bk.job.execute.engine.prepare.JobTaskContext;
import com.tencent.bk.job.execute.model.FileSourceDTO;
import com.tencent.bk.job.execute.model.StepInstanceBaseDTO;
import com.tencent.bk.job.execute.model.StepInstanceDTO;
import com.tencent.bk.job.execute.service.AgentService;
import com.tencent.bk.job.execute.service.TaskInstanceService;
Expand Down Expand Up @@ -89,20 +90,15 @@ public void prepareLocalFilesAsync(
List<FileSourceDTO> fileSourceList,
LocalFilePrepareTaskResultHandler resultHandler
) {
fillLocalFileSourceHost(fileSourceList, stepInstance);

if (!JobConstants.FILE_STORAGE_BACKEND_ARTIFACTORY.equals(
localFileConfigForExecute.getStorageBackend()
)) {
log.info("artifactory is not enable, not need to prepare local file");
resultHandler.onSuccess(new NFSLocalFilePrepareTask(false));
return;
}
fileSourceList.forEach(fileSourceDTO -> {
if (fileSourceDTO.getFileType() == TaskFileTypeEnum.LOCAL.getType() || fileSourceDTO.isLocalUpload()) {
fileSourceDTO.setServers(agentService.getLocalServersDTO());
}
});
// 更新本地文件任务内容
taskInstanceService.updateResolvedSourceFile(stepInstance.getId(), fileSourceList);
ArtifactoryLocalFilePrepareTask task = new ArtifactoryLocalFilePrepareTask(
stepInstance,
false,
Expand All @@ -118,6 +114,16 @@ public void prepareLocalFilesAsync(
task.execute();
}

private void fillLocalFileSourceHost(List<FileSourceDTO> fileSourceList, StepInstanceBaseDTO stepInstance) {
fileSourceList.forEach(fileSourceDTO -> {
if (fileSourceDTO.getFileType() == TaskFileTypeEnum.LOCAL.getType() || fileSourceDTO.isLocalUpload()) {
fileSourceDTO.setServers(agentService.getLocalServersDTO());
}
});
// 更新本地文件任务内容
taskInstanceService.updateResolvedSourceFile(stepInstance.getId(), fileSourceList);
}

public void clearPreparedTmpFile(long stepInstanceId) {
// 本地文件暂不支持实时清理,依赖定时清理
}
Expand Down

0 comments on commit a044d5c

Please sign in to comment.