From 32a8241ef2c89ab286727eb393a8ac6bc19fd2ae Mon Sep 17 00:00:00 2001 From: Wenjun Ruan Date: Mon, 28 Nov 2022 21:09:50 +0800 Subject: [PATCH] Don't source env file in task, this will override tenant's environment (#13028) --- .../plugin/task/api/ShellCommandExecutor.java | 8 -------- .../plugin/task/api/TaskExecutionContext.java | 5 ----- .../worker/runner/WorkerTaskExecuteRunnable.java | 4 ---- script/env/dolphinscheduler_env.sh | 16 ---------------- 4 files changed, 33 deletions(-) diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java index d92f8e42ce..ec96122205 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java @@ -95,10 +95,6 @@ public class ShellCommandExecutor extends AbstractCommandExecutor { sb.append("cd /d %~dp0").append(System.lineSeparator()); if (StringUtils.isNotBlank(taskRequest.getEnvironmentConfig())) { sb.append(taskRequest.getEnvironmentConfig()).append(System.lineSeparator()); - } else { - if (taskRequest.getEnvFile() != null) { - sb.append("call ").append(taskRequest.getEnvFile()).append(System.lineSeparator()); - } } } else { sb.append("#!/bin/bash").append(System.lineSeparator()); @@ -106,10 +102,6 @@ public class ShellCommandExecutor extends AbstractCommandExecutor { sb.append("cd $BASEDIR").append(System.lineSeparator()); if (StringUtils.isNotBlank(taskRequest.getEnvironmentConfig())) { sb.append(taskRequest.getEnvironmentConfig()).append(System.lineSeparator()); - } else { - if (taskRequest.getEnvFile() != null) { - sb.append("source ").append(taskRequest.getEnvFile()).append(System.lineSeparator()); - } } } sb.append(execCommand); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskExecutionContext.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskExecutionContext.java index ca89b4f8aa..e33ebcd59f 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskExecutionContext.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskExecutionContext.java @@ -166,11 +166,6 @@ public class TaskExecutionContext implements Serializable { */ private String taskParams; - /** - * envFile - */ - private String envFile; - /** * environmentConfig */ diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/WorkerTaskExecuteRunnable.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/WorkerTaskExecuteRunnable.java index e4ef748eee..d8c815dccc 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/WorkerTaskExecuteRunnable.java +++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/WorkerTaskExecuteRunnable.java @@ -196,10 +196,6 @@ public abstract class WorkerTaskExecuteRunnable implements Runnable { taskExecutionContext.setStartTime(taskStartTime); logger.info("Set task startTime: {}", taskStartTime); - String systemEnvPath = CommonUtils.getSystemEnvPath(); - taskExecutionContext.setEnvFile(systemEnvPath); - logger.info("Set task envFile: {}", systemEnvPath); - String taskAppId = String.format("%s_%s", taskExecutionContext.getProcessInstanceId(), taskExecutionContext.getTaskInstanceId()); taskExecutionContext.setTaskAppId(taskAppId); diff --git a/script/env/dolphinscheduler_env.sh b/script/env/dolphinscheduler_env.sh index 6701e9f49c..967f324259 100755 --- a/script/env/dolphinscheduler_env.sh +++ b/script/env/dolphinscheduler_env.sh @@ -15,26 +15,10 @@ # limitations under the License. # -# JAVA_HOME, will use it to start DolphinScheduler server -export JAVA_HOME=${JAVA_HOME:-/opt/java/openjdk} # Never put sensitive config such as database password here in your production environment, # this file will be sourced everytime a new task is executed. -# Tasks related configurations, need to change the configuration if you use the related tasks. -export HADOOP_HOME=${HADOOP_HOME:-/opt/soft/hadoop} -export HADOOP_CONF_DIR=${HADOOP_CONF_DIR:-/opt/soft/hadoop/etc/hadoop} -export SPARK_HOME=${SPARK_HOME:-/opt/soft/spark} -export PYTHON_HOME=${PYTHON_HOME:-/opt/soft/python} -export HIVE_HOME=${HIVE_HOME:-/opt/soft/hive} -export FLINK_HOME=${FLINK_HOME:-/opt/soft/flink} -export DATAX_HOME=${DATAX_HOME:-/opt/soft/datax} -export SEATUNNEL_HOME=${SEATUNNEL_HOME:-/opt/soft/seatunnel} -export CHUNJUN_HOME=${CHUNJUN_HOME:-/opt/soft/chunjun} -export LINKIS_HOME=${LINKIS_HOME:-/opt/soft/linkis} - -export PATH=$HADOOP_HOME/bin:$SPARK_HOME/bin:$PYTHON_HOME/bin:$JAVA_HOME/bin:$HIVE_HOME/bin:$FLINK_HOME/bin:$DATAX_HOME/bin:$SEATUNNEL_HOME/bin:$CHUNJUN_HOME/bin:$PATH - # applicationId auto collection related configuration, the following configurations are unnecessary if setting appId.collect=log #export HADOOP_CLASSPATH=`hadoop classpath`:${DOLPHINSCHEDULER_HOME}/tools/libs/* #export SPARK_DIST_CLASSPATH=$HADOOP_CLASSPATH:$SPARK_DIST_CLASS_PATH