You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ki...@apache.org on 2021/07/29 10:32:22 UTC

[dolphinscheduler] branch 1.3.7-prepare updated: [1.3.7-prepare#5552][Bug][Master] remove check with executePath when … (#5846)

This is an automated email from the ASF dual-hosted git repository.

kirs pushed a commit to branch 1.3.7-prepare
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/1.3.7-prepare by this push:
     new d025812  [1.3.7-prepare#5552][Bug][Master] remove check with executePath when … (#5846)
d025812 is described below

commit d02581226799dc421e303f88f7ccdc4cfed6832b
Author: Kirs <ac...@163.com>
AuthorDate: Thu Jul 29 18:32:16 2021 +0800

    [1.3.7-prepare#5552][Bug][Master] remove check with executePath when … (#5846)
    
    * [1.3.7-prepare#5552][Bug][Master] remove check with executePath when kill yarn job
    pr #5552
    issue #5550
    
    * update method name
---
 .../dolphinscheduler/common/utils/FileUtils.java    | 21 +++++++++++++++++++++
 .../dolphinscheduler/server/utils/ProcessUtils.java | 12 +++++++-----
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java
index e64c082..7c4a43c 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java
@@ -132,6 +132,27 @@ public class FileUtils {
     }
 
     /**
+     * Create a new work dir, if it exists, delete it and create it again
+     *
+     * @param execLocalPath execute local path
+     * @throws IOException errors
+     */
+    public static void createWorkDir(String execLocalPath) throws IOException {
+        //if work dir exists, first delete
+        File execLocalPathFile = new File(execLocalPath);
+
+        if (execLocalPathFile.exists()) {
+            org.apache.commons.io.FileUtils.forceDelete(execLocalPathFile);
+        }
+
+        //create work dir
+        org.apache.commons.io.FileUtils.forceMkdir(execLocalPathFile);
+        String mkdirLog = "create dir success " + execLocalPath;
+        LoggerUtils.logInfo(Optional.ofNullable(logger), mkdirLog);
+        LoggerUtils.logInfo(Optional.ofNullable(taskLoggerThreadLocal.get()), mkdirLog);
+    }
+
+    /**
      * create directory and user
      * @param execLocalPath execute local path
      * @param userName user name
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java
index dcbb7c4..b79ddce 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java
@@ -430,12 +430,14 @@ public class ProcessUtils {
                 }
             }
             if (StringUtils.isNotEmpty(log)) {
-                List<String> appIds = LoggerUtils.getAppIds(log, logger);
-                String workerDir = taskExecutionContext.getExecutePath();
-                if (StringUtils.isEmpty(workerDir)) {
-                    logger.error("task instance work dir is empty");
-                    throw new RuntimeException("task instance work dir is empty");
+                if (StringUtils.isEmpty(taskExecutionContext.getExecutePath())) {
+                    taskExecutionContext.setExecutePath(FileUtils.getProcessExecDir(taskExecutionContext.getProjectId(),
+                            taskExecutionContext.getProcessDefineId(),
+                            taskExecutionContext.getProcessInstanceId(),
+                            taskExecutionContext.getTaskInstanceId()));
                 }
+                FileUtils.createWorkDir(taskExecutionContext.getExecutePath());
+                List<String> appIds = LoggerUtils.getAppIds(log, logger);
                 if (CollectionUtils.isNotEmpty(appIds)) {
                     cancelApplication(appIds, logger, taskExecutionContext.getTenantCode(), taskExecutionContext.getExecutePath());
                     return appIds;