Skip to content

Commit

Permalink
Merge pull request #1781 from jsonwan/3.5.x
Browse files Browse the repository at this point in the history
bugfix: 二进制环境使用NFS作为存储后端时分发本地文件失败 #1779
  • Loading branch information
wangyu096 authored Feb 28, 2023
2 parents 7f1bbd2 + 4436a23 commit ed58af9
Showing 1 changed file with 23 additions and 0 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.ServersDTO;
import com.tencent.bk.job.execute.service.AgentService;
import com.tencent.bk.job.execute.service.TaskInstanceService;
import com.tencent.bk.job.manage.common.consts.task.TaskFileTypeEnum;
Expand Down Expand Up @@ -89,6 +90,8 @@ public void prepareLocalFilesAsync(
List<FileSourceDTO> fileSourceList,
LocalFilePrepareTaskResultHandler resultHandler
) {
fillLocalFileSourceHost(fileSourceList, stepInstanceId);

if (!JobConstants.FILE_STORAGE_BACKEND_ARTIFACTORY.equals(
localFileConfigForExecute.getStorageBackend()
)) {
Expand Down Expand Up @@ -117,6 +120,26 @@ public void prepareLocalFilesAsync(
task.execute();
}

private void fillLocalFileSourceHost(List<FileSourceDTO> fileSourceList, long stepInstanceId) {
ServersDTO localServersDTO = agentService.getLocalServersDTO();
int localFileSourceCount = 0;
for (FileSourceDTO fileSourceDTO : fileSourceList) {
if (fileSourceDTO.getFileType() == TaskFileTypeEnum.LOCAL.getType() || fileSourceDTO.isLocalUpload()) {
fileSourceDTO.setServers(localServersDTO);
localFileSourceCount += 1;
}
}
if (localFileSourceCount > 0) {
log.info(
"localServer({}) has been set for {} local fileSource",
localServersDTO.getIpList(),
localFileSourceCount
);
}
// 更新本地文件任务内容
taskInstanceService.updateResolvedSourceFile(stepInstanceId, fileSourceList);
}

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

0 comments on commit ed58af9

Please sign in to comment.