From 74ed7856bc81ebc7942d54661cf1f15833ae8345 Mon Sep 17 00:00:00 2001 From: Aaron Wang Date: Tue, 16 May 2023 18:11:58 +0800 Subject: [PATCH] [Bug-14105][Task] Replace default tenant when downloading resource (#14106) --- .../plugin/storage/hdfs/HdfsStorageOperator.java | 2 +- .../server/worker/utils/TaskExecutionCheckerUtils.java | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dolphinscheduler-storage-plugin/dolphinscheduler-storage-hdfs/src/main/java/org/apache/dolphinscheduler/plugin/storage/hdfs/HdfsStorageOperator.java b/dolphinscheduler-storage-plugin/dolphinscheduler-storage-hdfs/src/main/java/org/apache/dolphinscheduler/plugin/storage/hdfs/HdfsStorageOperator.java index 405c081472..9c3bb73e14 100644 --- a/dolphinscheduler-storage-plugin/dolphinscheduler-storage-hdfs/src/main/java/org/apache/dolphinscheduler/plugin/storage/hdfs/HdfsStorageOperator.java +++ b/dolphinscheduler-storage-plugin/dolphinscheduler-storage-hdfs/src/main/java/org/apache/dolphinscheduler/plugin/storage/hdfs/HdfsStorageOperator.java @@ -312,7 +312,7 @@ public class HdfsStorageOperator implements Closeable, StorageOperate { } @Override - public void download(String bucketName, String srcHdfsFilePath, String dstFile, boolean deleteSource, + public void download(String tenantCode, String srcHdfsFilePath, String dstFile, boolean deleteSource, boolean overwrite) throws IOException { copyHdfsToLocal(srcHdfsFilePath, dstFile, deleteSource, overwrite); } diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/utils/TaskExecutionCheckerUtils.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/utils/TaskExecutionCheckerUtils.java index 1ae02fdd7e..741d0d568c 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/utils/TaskExecutionCheckerUtils.java +++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/utils/TaskExecutionCheckerUtils.java @@ -110,13 +110,16 @@ public class TaskExecutionCheckerUtils { TaskExecutionContext taskExecutionContext) { String execLocalPath = taskExecutionContext.getExecutePath(); String tenant = taskExecutionContext.getTenantCode(); + String actualTenant = + TenantConstants.DEFAULT_TENANT_CODE.equals(tenant) ? TenantConstants.BOOTSTRAPT_SYSTEM_USER : tenant; + Map projectRes = taskExecutionContext.getResources(); if (MapUtils.isEmpty(projectRes)) { return; } List> downloadFiles = new ArrayList<>(); projectRes.keySet().forEach(fullName -> { - String fileName = storageOperate.getResourceFileName(tenant, fullName); + String fileName = storageOperate.getResourceFileName(actualTenant, fullName); projectRes.put(fullName, fileName); File resFile = new File(execLocalPath, fileName); boolean notExist = !resFile.exists(); @@ -138,7 +141,7 @@ public class TaskExecutionCheckerUtils { log.info("get resource file from path:{}", fullName); long resourceDownloadStartTime = System.currentTimeMillis(); - storageOperate.download(taskExecutionContext.getTenantCode(), fullName, + storageOperate.download(actualTenant, fullName, execLocalPath + File.separator + fileName, false, true); WorkerServerMetrics