This is an automated email from the ASF dual-hosted git repository.
wenjun pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 806f05155f [Fix-16991] Missing environmentConfig when
retry/failover/recover task instance (#16998)
806f05155f is described below
commit 806f05155f1df531609ef4e1b11590799e65a97f
Author: Wenjun Ruan <[email protected]>
AuthorDate: Fri Feb 7 12:09:17 2025 +0800
[Fix-16991] Missing environmentConfig when retry/failover/recover task
instance (#16998)
---
.../dao/repository/IEnvironmentDao.java | 27 +++++
.../dao/repository/impl/EnvironmentDaoImpl.java | 42 +++++++
.../dao/utils/TaskInstanceUtils.java | 80 --------------
.../dao/utils/TaskInstanceUtilsTest.java | 43 -------
.../engine/executor/plugin/fake/LogicFakeTask.java | 8 +-
.../task/runnable/AbstractTaskInstanceFactory.java | 12 --
.../task/runnable/FirstRunTaskInstanceFactory.java | 1 -
.../task/runnable/TaskExecutionContextBuilder.java | 44 +++-----
.../master/runner/TaskExecutionContextFactory.java | 110 +++++++++++-------
.../integration/WorkflowTestCaseContext.java | 3 +
.../WorkflowTestCaseContextFactory.java | 14 +++
.../cases/WorkflowInstanceFailoverTestCase.java | 36 ++++++
.../integration/cases/WorkflowStartTestCase.java | 32 +++++-
...th_one_running_fake_task_using_environment.yaml | 123 +++++++++++++++++++++
...th_one_fake_task_using_environment_success.yaml | 72 ++++++++++++
.../plugin/task/api/TaskExecutionContext.java | 4 -
16 files changed, 440 insertions(+), 211 deletions(-)
diff --git
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/IEnvironmentDao.java
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/IEnvironmentDao.java
new file mode 100644
index 0000000000..4bcd598804
--- /dev/null
+++
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/IEnvironmentDao.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.dao.repository;
+
+import org.apache.dolphinscheduler.dao.entity.Environment;
+
+import java.util.Optional;
+
+public interface IEnvironmentDao extends IDao<Environment> {
+
+ Optional<Environment> queryByEnvironmentCode(Long environmentCode);
+}
diff --git
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/EnvironmentDaoImpl.java
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/EnvironmentDaoImpl.java
new file mode 100644
index 0000000000..00f639e55c
--- /dev/null
+++
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/EnvironmentDaoImpl.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.dao.repository.impl;
+
+import org.apache.dolphinscheduler.dao.entity.Environment;
+import org.apache.dolphinscheduler.dao.mapper.EnvironmentMapper;
+import org.apache.dolphinscheduler.dao.repository.BaseDao;
+import org.apache.dolphinscheduler.dao.repository.IEnvironmentDao;
+
+import java.util.Optional;
+
+import lombok.NonNull;
+
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class EnvironmentDaoImpl extends BaseDao<Environment,
EnvironmentMapper> implements IEnvironmentDao {
+
+ public EnvironmentDaoImpl(@NonNull EnvironmentMapper environmentMapper) {
+ super(environmentMapper);
+ }
+
+ @Override
+ public Optional<Environment> queryByEnvironmentCode(Long environmentCode) {
+ return
Optional.ofNullable(mybatisMapper.queryByEnvironmentCode(environmentCode));
+ }
+}
diff --git
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtils.java
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtils.java
deleted file mode 100644
index 8c7039c699..0000000000
---
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtils.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dolphinscheduler.dao.utils;
-
-import org.apache.dolphinscheduler.dao.entity.TaskInstance;
-
-public class TaskInstanceUtils {
-
- /**
- * Copy the property of given source {@link TaskInstance} to target.
- *
- * @param source Given task instance, copy from.
- * @param target Given task instance, copy to
- * @return a soft copy of given task instance.
- */
- public static void copyTaskInstance(TaskInstance source, TaskInstance
target) {
- target.setId(source.getId());
- target.setName(source.getName());
- target.setTaskType(source.getTaskType());
- target.setWorkflowInstanceId(source.getWorkflowInstanceId());
- target.setWorkflowInstanceName(source.getWorkflowInstanceName());
- target.setProjectCode(source.getProjectCode());
- target.setTaskCode(source.getTaskCode());
- target.setTaskDefinitionVersion(source.getTaskDefinitionVersion());
- target.setWorkflowInstanceName(source.getWorkflowInstanceName());
- target.setTaskGroupPriority(source.getTaskGroupPriority());
- target.setState(source.getState());
- target.setFirstSubmitTime(source.getFirstSubmitTime());
- target.setSubmitTime(source.getSubmitTime());
- target.setStartTime(source.getStartTime());
- target.setEndTime(source.getEndTime());
- target.setHost(source.getHost());
- target.setExecutePath(source.getExecutePath());
- target.setLogPath(source.getLogPath());
- target.setRetryTimes(source.getRetryTimes());
- target.setAlertFlag(source.getAlertFlag());
- target.setWorkflowInstance(source.getWorkflowInstance());
- target.setWorkflowDefinition(source.getWorkflowDefinition());
- target.setTaskDefine(source.getTaskDefine());
- target.setPid(source.getPid());
- target.setAppLink(source.getAppLink());
- target.setFlag(source.getFlag());
- // todo: we need to cpoy the task params and then copy
switchDependency, since the setSwitchDependency rely on
- // task params, this is really a very bad practice.
- target.setTaskParams(source.getTaskParams());
- target.setDuration(source.getDuration());
- target.setMaxRetryTimes(source.getMaxRetryTimes());
- target.setRetryInterval(source.getRetryInterval());
- target.setTaskInstancePriority(source.getTaskInstancePriority());
- target.setWorkerGroup(source.getWorkerGroup());
- target.setEnvironmentCode(source.getEnvironmentCode());
- target.setEnvironmentConfig(source.getEnvironmentConfig());
- target.setExecutorId(source.getExecutorId());
- target.setVarPool(source.getVarPool());
- target.setExecutorName(source.getExecutorName());
- target.setDelayTime(source.getDelayTime());
- target.setDryRun(source.getDryRun());
- target.setTaskGroupId(source.getTaskGroupId());
- target.setCpuQuota(source.getCpuQuota());
- target.setMemoryMax(source.getMemoryMax());
- target.setTaskExecuteType(source.getTaskExecuteType());
- target.setTestFlag(source.getTestFlag());
- }
-
-}
diff --git
a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtilsTest.java
b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtilsTest.java
deleted file mode 100644
index cb74aeb44e..0000000000
---
a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/TaskInstanceUtilsTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dolphinscheduler.dao.utils;
-
-import org.apache.dolphinscheduler.common.utils.JSONUtils;
-import org.apache.dolphinscheduler.dao.entity.TaskInstance;
-
-import java.util.Date;
-import java.util.HashMap;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-class TaskInstanceUtilsTest {
-
- @Test
- void copyTaskInstance() {
- TaskInstance source = new TaskInstance();
- source.setId(1);
- source.setName("source");
- source.setSubmitTime(new Date());
- source.setTaskParams(JSONUtils.toJsonString(new HashMap<>()));
- TaskInstance target = new TaskInstance();
- TaskInstanceUtils.copyTaskInstance(source, target);
- Assertions.assertEquals(target.getId(), source.getId());
- Assertions.assertEquals(target.getName(), source.getName());
- }
-}
diff --git
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/executor/plugin/fake/LogicFakeTask.java
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/executor/plugin/fake/LogicFakeTask.java
index b05dc8cff4..409d529761 100644
---
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/executor/plugin/fake/LogicFakeTask.java
+++
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/executor/plugin/fake/LogicFakeTask.java
@@ -26,6 +26,8 @@ import
org.apache.dolphinscheduler.server.master.engine.executor.plugin.Abstract
import
org.apache.dolphinscheduler.server.master.engine.executor.plugin.ITaskParameterDeserializer;
import
org.apache.dolphinscheduler.server.master.exception.MasterTaskExecuteException;
+import org.apache.commons.lang3.StringUtils;
+
import lombok.extern.slf4j.Slf4j;
import com.fasterxml.jackson.core.type.TypeReference;
@@ -51,9 +53,13 @@ public class LogicFakeTask extends
AbstractLogicTask<LogicFakeTaskParameters> {
try {
log.info("Begin to execute LogicFakeTask: {}",
taskExecutionContext.getTaskName());
- final String shellScript =
ParameterUtils.convertParameterPlaceholders(
+ String shellScript = ParameterUtils.convertParameterPlaceholders(
taskParameters.getShellScript(),
ParameterUtils.convert(taskExecutionContext.getPrepareParamsMap()));
+
+ if
(StringUtils.isNotEmpty(taskExecutionContext.getEnvironmentConfig())) {
+ shellScript = taskExecutionContext.getEnvironmentConfig() +
"\n" + shellScript;
+ }
final String[] cmd = {"/bin/sh", "-c", shellScript};
process = Runtime.getRuntime().exec(cmd);
int exitCode = process.waitFor();
diff --git
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/runnable/AbstractTaskInstanceFactory.java
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/runnable/AbstractTaskInstanceFactory.java
index 0db29c77a0..37993f9405 100644
---
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/runnable/AbstractTaskInstanceFactory.java
+++
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/runnable/AbstractTaskInstanceFactory.java
@@ -17,7 +17,6 @@
package org.apache.dolphinscheduler.server.master.engine.task.runnable;
-import org.apache.dolphinscheduler.dao.entity.Environment;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
@@ -62,7 +61,6 @@ public abstract class AbstractTaskInstanceFactory<BUILDER
extends ITaskInstanceF
result.setTaskInstancePriority(originTaskInstance.getTaskInstancePriority());
result.setWorkerGroup(originTaskInstance.getWorkerGroup());
result.setEnvironmentCode(originTaskInstance.getEnvironmentCode());
- result.setEnvironmentConfig(originTaskInstance.getEnvironmentConfig());
result.setExecutorId(originTaskInstance.getExecutorId());
result.setVarPool(originTaskInstance.getVarPool());
result.setExecutorName(originTaskInstance.getExecutorName());
@@ -116,14 +114,4 @@ public abstract class AbstractTaskInstanceFactory<BUILDER
extends ITaskInstanceF
taskInstance.setTestFlag(workflowInstance.getTestFlag());
}
- protected void injectEnvironmentConfigFromDB(TaskInstance taskInstance) {
- if
(EnvironmentUtils.isEnvironmentCodeEmpty(taskInstance.getEnvironmentCode())) {
- return;
- }
- Environment environment =
environmentMapper.queryByEnvironmentCode(taskInstance.getEnvironmentCode());
- if (environment == null) {
- throw new IllegalArgumentException("Cannot find the environment: "
+ taskInstance.getEnvironmentCode());
- }
- taskInstance.setEnvironmentConfig(environment.getConfig());
- }
}
diff --git
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/runnable/FirstRunTaskInstanceFactory.java
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/runnable/FirstRunTaskInstanceFactory.java
index 1d624295be..bdd0bd86b7 100644
---
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/runnable/FirstRunTaskInstanceFactory.java
+++
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/runnable/FirstRunTaskInstanceFactory.java
@@ -51,7 +51,6 @@ public class FirstRunTaskInstanceFactory extends
AbstractTaskInstanceFactory<Fir
TaskInstance taskInstance = new TaskInstance();
injectMetadataFromTaskDefinition(taskInstance, taskDefinition);
injectMetadataFromWorkflowInstance(taskInstance, workflowInstance);
- injectEnvironmentConfigFromDB(taskInstance);
taskInstance.setState(TaskExecutionStatus.SUBMITTED_SUCCESS);
taskInstance.setFirstSubmitTime(new Date());
diff --git
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/runnable/TaskExecutionContextBuilder.java
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/runnable/TaskExecutionContextBuilder.java
index b5df29ec86..edbfb9af4d 100644
---
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/runnable/TaskExecutionContextBuilder.java
+++
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/runnable/TaskExecutionContextBuilder.java
@@ -23,11 +23,9 @@ import org.apache.dolphinscheduler.common.enums.TimeoutFlag;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
-import org.apache.dolphinscheduler.dao.entity.WorkflowDefinition;
import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
import org.apache.dolphinscheduler.plugin.task.api.K8sTaskExecutionContext;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
-import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy;
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
import
org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper;
@@ -48,7 +46,11 @@ public class TaskExecutionContextBuilder {
return new TaskExecutionContextBuilder();
}
- private TaskExecutionContext taskExecutionContext = new
TaskExecutionContext();
+ private final TaskExecutionContext taskExecutionContext;
+
+ public TaskExecutionContextBuilder() {
+ this.taskExecutionContext = new TaskExecutionContext();
+ }
/**
* build taskInstance related info
@@ -56,7 +58,7 @@ public class TaskExecutionContextBuilder {
* @param taskInstance taskInstance
* @return TaskExecutionContextBuilder
*/
- public TaskExecutionContextBuilder
buildTaskInstanceRelatedInfo(TaskInstance taskInstance) {
+ public TaskExecutionContextBuilder buildTaskInstanceRelatedInfo(final
TaskInstance taskInstance) {
taskExecutionContext.setTaskInstanceId(taskInstance.getId());
taskExecutionContext.setTaskName(taskInstance.getName());
taskExecutionContext.setFirstSubmitTime(DateUtils.dateToTimeStamp(taskInstance.getFirstSubmitTime()));
@@ -64,19 +66,17 @@ public class TaskExecutionContextBuilder {
taskExecutionContext.setTaskType(taskInstance.getTaskType());
taskExecutionContext.setLogPath(taskInstance.getLogPath());
taskExecutionContext.setWorkerGroup(taskInstance.getWorkerGroup());
-
taskExecutionContext.setEnvironmentConfig(taskInstance.getEnvironmentConfig());
taskExecutionContext.setHost(taskInstance.getHost());
taskExecutionContext.setVarPool(taskInstance.getVarPool());
taskExecutionContext.setDryRun(taskInstance.getDryRun());
taskExecutionContext.setTestFlag(taskInstance.getTestFlag());
-
taskExecutionContext.setCurrentExecutionStatus(TaskExecutionStatus.SUBMITTED_SUCCESS);
taskExecutionContext.setCpuQuota(taskInstance.getCpuQuota());
taskExecutionContext.setMemoryMax(taskInstance.getMemoryMax());
taskExecutionContext.setAppIds(taskInstance.getAppLink());
return this;
}
- public TaskExecutionContextBuilder
buildTaskDefinitionRelatedInfo(TaskDefinition taskDefinition) {
+ public TaskExecutionContextBuilder buildTaskDefinitionRelatedInfo(final
TaskDefinition taskDefinition) {
// todo: remove the timeout setting here the timeout strategy should
be used at master
taskExecutionContext.setTaskTimeout(Integer.MAX_VALUE);
if (taskDefinition.getTimeoutFlag() == TimeoutFlag.OPEN) {
@@ -97,7 +97,7 @@ public class TaskExecutionContextBuilder {
* @param workflowInstance processInstance
* @return TaskExecutionContextBuilder
*/
- public TaskExecutionContextBuilder
buildProcessInstanceRelatedInfo(WorkflowInstance workflowInstance) {
+ public TaskExecutionContextBuilder buildProcessInstanceRelatedInfo(final
WorkflowInstance workflowInstance) {
taskExecutionContext.setWorkflowInstanceId(workflowInstance.getId());
taskExecutionContext.setScheduleTime(DateUtils.dateToTimeStamp(workflowInstance.getScheduleTime()));
taskExecutionContext.setGlobalParams(workflowInstance.getGlobalParams());
@@ -110,20 +110,7 @@ public class TaskExecutionContextBuilder {
return this;
}
- /**
- * build processDefinition related info
- *
- * @param workflowDefinition processDefinition
- * @return TaskExecutionContextBuilder
- */
- public TaskExecutionContextBuilder
buildProcessDefinitionRelatedInfo(WorkflowDefinition workflowDefinition) {
-
taskExecutionContext.setWorkflowDefinitionCode(workflowDefinition.getCode());
-
taskExecutionContext.setWorkflowDefinitionVersion(workflowDefinition.getVersion());
-
taskExecutionContext.setProjectCode(workflowDefinition.getProjectCode());
- return this;
- }
-
- public TaskExecutionContextBuilder
buildResourceParametersInfo(ResourceParametersHelper parametersHelper) {
+ public TaskExecutionContextBuilder buildResourceParameters(final
ResourceParametersHelper parametersHelper) {
taskExecutionContext.setResourceParametersHelper(parametersHelper);
return this;
}
@@ -135,7 +122,7 @@ public class TaskExecutionContextBuilder {
* @return TaskExecutionContextBuilder
*/
- public TaskExecutionContextBuilder
buildK8sTaskRelatedInfo(K8sTaskExecutionContext k8sTaskExecutionContext) {
+ public TaskExecutionContextBuilder buildK8sTaskRelatedInfo(final
K8sTaskExecutionContext k8sTaskExecutionContext) {
taskExecutionContext.setK8sTaskExecutionContext(k8sTaskExecutionContext);
return this;
}
@@ -146,7 +133,7 @@ public class TaskExecutionContextBuilder {
* @param propertyMap
* @return
*/
- public TaskExecutionContextBuilder buildParamInfo(Map<String, Property>
propertyMap) {
+ public TaskExecutionContextBuilder buildPrepareParams(final Map<String,
Property> propertyMap) {
taskExecutionContext.setPrepareParamsMap(propertyMap);
return this;
}
@@ -157,16 +144,21 @@ public class TaskExecutionContextBuilder {
* @param businessParamsMap
* @return
*/
- public TaskExecutionContextBuilder buildBusinessParamsMap(Map<String,
Property> businessParamsMap) {
+ public TaskExecutionContextBuilder buildBusinessParams(final Map<String,
Property> businessParamsMap) {
taskExecutionContext.setParamsMap(businessParamsMap);
return this;
}
- public TaskExecutionContextBuilder buildWorkflowInstanceHost(String
masterHost) {
+ public TaskExecutionContextBuilder buildWorkflowInstanceHost(final String
masterHost) {
taskExecutionContext.setWorkflowInstanceHost(masterHost);
return this;
}
+ public TaskExecutionContextBuilder buildEnvironmentConfig(final String
environmentConfig) {
+ taskExecutionContext.setEnvironmentConfig(environmentConfig);
+ return this;
+ }
+
/**
* create
*
diff --git
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/TaskExecutionContextFactory.java
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/TaskExecutionContextFactory.java
index 2eda4689d7..327cc6de99 100644
---
a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/TaskExecutionContextFactory.java
+++
b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/TaskExecutionContextFactory.java
@@ -22,10 +22,13 @@ import static
org.apache.dolphinscheduler.plugin.task.api.TaskConstants.NAMESPAC
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.DataSource;
+import org.apache.dolphinscheduler.dao.entity.Environment;
import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.dao.entity.WorkflowDefinition;
import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
+import org.apache.dolphinscheduler.dao.repository.IEnvironmentDao;
+import org.apache.dolphinscheduler.dao.utils.EnvironmentUtils;
import org.apache.dolphinscheduler.plugin.task.api.K8sTaskExecutionContext;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
@@ -46,6 +49,7 @@ import org.apache.commons.lang3.StringUtils;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
@@ -65,60 +69,48 @@ public class TaskExecutionContextFactory {
@Autowired
private MasterConfig masterConfig;
- public TaskExecutionContext
createTaskExecutionContext(TaskExecutionContextCreateRequest request) {
- TaskInstance taskInstance = request.getTaskInstance();
- WorkflowInstance workflowInstance = request.getWorkflowInstance();
- WorkflowDefinition workflowDefinition =
request.getWorkflowDefinition();
- Project project = request.getProject();
-
- ResourceParametersHelper resources =
TaskPluginManager.getTaskChannel(taskInstance.getTaskType())
- .parseParameters(taskInstance.getTaskParams())
- .getResources();
- setTaskResourceInfo(resources);
-
- Map<String, Property> businessParamsMap =
curingParamsService.preBuildBusinessParams(workflowInstance);
+ @Autowired
+ private IEnvironmentDao environmentDao;
- AbstractParameters baseParam =
-
TaskPluginManager.parseTaskParameters(taskInstance.getTaskType(),
taskInstance.getTaskParams());
+ public TaskExecutionContext
createTaskExecutionContext(TaskExecutionContextCreateRequest request) {
+ final TaskInstance taskInstance = request.getTaskInstance();
+ final WorkflowInstance workflowInstance =
request.getWorkflowInstance();
+ final WorkflowDefinition workflowDefinition =
request.getWorkflowDefinition();
+ final Project project = request.getProject();
- Map<String, Property> propertyMap =
- curingParamsService.paramParsingPreparation(taskInstance,
baseParam, workflowInstance,
- project.getName(), workflowDefinition.getName());
- TaskExecutionContext taskExecutionContext =
TaskExecutionContextBuilder.get()
+ return TaskExecutionContextBuilder.get()
.buildWorkflowInstanceHost(masterConfig.getMasterAddress())
.buildTaskInstanceRelatedInfo(taskInstance)
+
.buildEnvironmentConfig(getEnvironmentConfigFromDB(taskInstance).orElse(null))
.buildTaskDefinitionRelatedInfo(request.getTaskDefinition())
.buildProcessInstanceRelatedInfo(request.getWorkflowInstance())
- .buildResourceParametersInfo(resources)
- .buildBusinessParamsMap(businessParamsMap)
- .buildParamInfo(propertyMap)
+ .buildResourceParameters(getResourceParameters(taskInstance))
+ .buildBusinessParams(getBusinessParams(workflowInstance))
+ .buildPrepareParams(getPrepareParams(taskInstance,
workflowInstance, workflowDefinition, project))
+
.buildK8sTaskRelatedInfo(getK8sTaskExecutionContext(taskInstance))
.create();
-
- setK8sTaskRelatedInfo(taskExecutionContext, taskInstance);
- return taskExecutionContext;
- }
-
- public void setK8sTaskRelatedInfo(TaskExecutionContext
taskExecutionContext, TaskInstance taskInstance) {
- K8sTaskExecutionContext k8sTaskExecutionContext =
setK8sTaskRelation(taskInstance);
-
taskExecutionContext.setK8sTaskExecutionContext(k8sTaskExecutionContext);
}
- private void setTaskResourceInfo(ResourceParametersHelper
resourceParametersHelper) {
- if (Objects.isNull(resourceParametersHelper)) {
- return;
+ private ResourceParametersHelper getResourceParameters(final TaskInstance
taskInstance) {
+ final ResourceParametersHelper resourceParameters =
TaskPluginManager.getTaskChannel(taskInstance.getTaskType())
+ .parseParameters(taskInstance.getTaskParams())
+ .getResources();
+ if (resourceParameters != null) {
+ // todo: add DataSourceParametersAssembler to assemble
DataSourceParameters
+ resourceParameters.getResourceMap().forEach((type, map) -> {
+ switch (type) {
+ case DATASOURCE:
+ assembleDataSourceParameters(map);
+ break;
+ default:
+ break;
+ }
+ });
}
- resourceParametersHelper.getResourceMap().forEach((type, map) -> {
- switch (type) {
- case DATASOURCE:
- setTaskDataSourceResourceInfo(map);
- break;
- default:
- break;
- }
- });
+ return resourceParameters;
}
- private void setTaskDataSourceResourceInfo(Map<Integer,
AbstractResourceParameters> map) {
+ private void assembleDataSourceParameters(Map<Integer,
AbstractResourceParameters> map) {
if (MapUtils.isEmpty(map)) {
return;
}
@@ -135,7 +127,7 @@ public class TaskExecutionContextFactory {
});
}
- private K8sTaskExecutionContext setK8sTaskRelation(TaskInstance
taskInstance) {
+ private K8sTaskExecutionContext getK8sTaskExecutionContext(final
TaskInstance taskInstance) {
K8sTaskExecutionContext k8sTaskExecutionContext = null;
String namespace = "";
switch (taskInstance.getTaskType()) {
@@ -160,4 +152,36 @@ public class TaskExecutionContextFactory {
return k8sTaskExecutionContext;
}
+ private Map<String, Property> getBusinessParams(final WorkflowInstance
workflowInstance) {
+ return curingParamsService.preBuildBusinessParams(workflowInstance);
+ }
+
+ private Map<String, Property> getPrepareParams(final TaskInstance
taskInstance,
+ final WorkflowInstance
workflowInstance,
+ final WorkflowDefinition
workflowDefinition,
+ final Project project) {
+ final AbstractParameters baseParam =
TaskPluginManager.parseTaskParameters(
+ taskInstance.getTaskType(),
+ taskInstance.getTaskParams());
+
+ return curingParamsService.paramParsingPreparation(
+ taskInstance,
+ baseParam,
+ workflowInstance,
+ project.getName(),
+ workflowDefinition.getName());
+ }
+
+ private Optional<String> getEnvironmentConfigFromDB(final TaskInstance
taskInstance) {
+ if
(EnvironmentUtils.isEnvironmentCodeEmpty(taskInstance.getEnvironmentCode())) {
+ return Optional.empty();
+ }
+ final Optional<Environment> environmentOptional =
+
environmentDao.queryByEnvironmentCode(taskInstance.getEnvironmentCode());
+ if (!environmentOptional.isPresent()) {
+ throw new IllegalArgumentException("Cannot find the environment: "
+ taskInstance.getEnvironmentCode());
+ }
+ return Optional.ofNullable(environmentOptional.get().getConfig());
+ }
+
}
diff --git
a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/WorkflowTestCaseContext.java
b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/WorkflowTestCaseContext.java
index 7d152ea284..a0c5c83e2e 100644
---
a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/WorkflowTestCaseContext.java
+++
b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/WorkflowTestCaseContext.java
@@ -17,6 +17,7 @@
package org.apache.dolphinscheduler.server.master.integration;
+import org.apache.dolphinscheduler.dao.entity.Environment;
import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import org.apache.dolphinscheduler.dao.entity.TaskGroup;
@@ -52,6 +53,8 @@ public class WorkflowTestCaseContext {
private List<TaskGroup> taskGroups;
+ private List<Environment> environments;
+
public WorkflowDefinition getOneWorkflow() {
if (CollectionUtils.isEmpty(workflows)) {
throw new IllegalStateException("workflows is empty");
diff --git
a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/WorkflowTestCaseContextFactory.java
b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/WorkflowTestCaseContextFactory.java
index 1a5804fd99..c5de1a4d5d 100644
---
a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/WorkflowTestCaseContextFactory.java
+++
b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/WorkflowTestCaseContextFactory.java
@@ -17,6 +17,7 @@
package org.apache.dolphinscheduler.server.master.integration;
+import org.apache.dolphinscheduler.dao.entity.Environment;
import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog;
@@ -28,6 +29,7 @@ import
org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
import org.apache.dolphinscheduler.dao.entity.WorkflowTaskRelation;
import org.apache.dolphinscheduler.dao.entity.WorkflowTaskRelationLog;
import org.apache.dolphinscheduler.dao.mapper.WorkflowTaskRelationMapper;
+import org.apache.dolphinscheduler.dao.repository.IEnvironmentDao;
import org.apache.dolphinscheduler.dao.repository.ProjectDao;
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao;
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionLogDao;
@@ -79,6 +81,9 @@ public class WorkflowTestCaseContextFactory {
@Autowired
private TaskGroupDao taskGroupDao;
+ @Autowired
+ private IEnvironmentDao environmentDao;
+
public WorkflowTestCaseContext initializeContextFromYaml(final String
yamlPath) {
final WorkflowTestCaseContext workflowTestCaseContext =
YamlFactory.load(yamlPath);
initializeProjectToDB(workflowTestCaseContext.getProject());
@@ -94,6 +99,9 @@ public class WorkflowTestCaseContextFactory {
if
(CollectionUtils.isNotEmpty(workflowTestCaseContext.getTaskGroups())) {
initializeTaskGroupsToDB(workflowTestCaseContext.getTaskGroups());
}
+ if
(CollectionUtils.isNotEmpty(workflowTestCaseContext.getEnvironments())) {
+
initializeEnvironmentToDB(workflowTestCaseContext.getEnvironments());
+ }
return workflowTestCaseContext;
}
@@ -148,4 +156,10 @@ public class WorkflowTestCaseContextFactory {
}
}
+ private void initializeEnvironmentToDB(final List<Environment>
environments) {
+ for (final Environment environment : environments) {
+ environmentDao.insert(environment);
+ }
+ }
+
}
diff --git
a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/cases/WorkflowInstanceFailoverTestCase.java
b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/cases/WorkflowInstanceFailoverTestCase.java
index 43571d2b73..4ef678fe51 100644
---
a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/cases/WorkflowInstanceFailoverTestCase.java
+++
b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/cases/WorkflowInstanceFailoverTestCase.java
@@ -146,6 +146,42 @@ public class WorkflowInstanceFailoverTestCase extends
AbstractMasterIntegrationT
}
+ @Test
+ public void
testGlobalFailover_runningWorkflow_withRunningTasksUsingEnvironment() {
+ final String yaml =
"/it/failover/running_workflowInstance_with_one_running_fake_task_using_environment.yaml";
+ final WorkflowTestCaseContext context =
workflowTestCaseContextFactory.initializeContextFromYaml(yaml);
+ final WorkflowDefinition workflow = context.getOneWorkflow();
+
+ systemEventBus.publish(GlobalMasterFailoverEvent.of(new Date()));
+
+ await()
+ .atMost(Duration.ofMinutes(1))
+ .untilAsserted(() -> {
+ assertThat(repository.queryWorkflowInstance(workflow))
+ .hasSize(1)
+ .anySatisfy(workflowInstance -> {
+ assertThat(workflowInstance.getState())
+
.isEqualTo(WorkflowExecutionStatus.SUCCESS);
+ assertThat(workflowInstance.getName())
+ .isEqualTo(
+
"running_workflowInstance_with_one_running_fake_task_using_environment-20240816071251690");
+ });
+ final List<TaskInstance> taskInstances =
repository.queryTaskInstance(workflow);
+ assertThat(taskInstances)
+ .hasSize(2);
+ assertThat(taskInstances.get(0))
+ .matches(t -> t.getState() ==
TaskExecutionStatus.NEED_FAULT_TOLERANCE)
+ .matches(t -> t.getFlag() == Flag.NO);
+
+ assertThat(taskInstances.get(1))
+ .matches(t -> t.getState() ==
TaskExecutionStatus.SUCCESS)
+ .matches(t -> t.getFlag() == Flag.YES)
+ .matches(t ->
StringUtils.isNotEmpty(t.getLogPath()));
+ });
+ masterContainer.assertAllResourceReleased();
+
+ }
+
@Test
public void testGlobalFailover_runningWorkflow_withSuccessTasks() {
final String yaml =
"/it/failover/running_workflowInstance_with_one_success_fake_task.yaml";
diff --git
a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/cases/WorkflowStartTestCase.java
b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/cases/WorkflowStartTestCase.java
index 1041a34a52..19650f8db7 100644
---
a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/cases/WorkflowStartTestCase.java
+++
b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/cases/WorkflowStartTestCase.java
@@ -131,7 +131,6 @@ public class WorkflowStartTestCase extends
AbstractMasterIntegrationTestCase {
final WorkflowOperator.WorkflowTriggerDTO workflowTriggerDTO =
WorkflowOperator.WorkflowTriggerDTO.builder()
.workflowDefinition(workflow)
.runWorkflowCommandParam(new RunWorkflowCommandParam())
- .dryRun(Flag.YES)
.build();
workflowOperator.manualTriggerWorkflow(workflowTriggerDTO);
@@ -153,6 +152,37 @@ public class WorkflowStartTestCase extends
AbstractMasterIntegrationTestCase {
masterContainer.assertAllResourceReleased();
}
+ @Test
+ @DisplayName("Test start a workflow with one fake task(A) using
environment config")
+ public void testStartWorkflow_with_oneSuccessTaskUsingEnvironmentConfig() {
+ final String yaml =
"/it/start/workflow_with_one_fake_task_using_environment_success.yaml";
+ final WorkflowTestCaseContext context =
workflowTestCaseContextFactory.initializeContextFromYaml(yaml);
+ final WorkflowDefinition workflow = context.getOneWorkflow();
+
+ final WorkflowOperator.WorkflowTriggerDTO workflowTriggerDTO =
WorkflowOperator.WorkflowTriggerDTO.builder()
+ .workflowDefinition(workflow)
+ .runWorkflowCommandParam(new RunWorkflowCommandParam())
+ .build();
+
+ final Integer workflowInstanceId =
workflowOperator.manualTriggerWorkflow(workflowTriggerDTO);
+
+ await()
+ .atMost(Duration.ofMinutes(1))
+ .untilAsserted(() -> {
+ Assertions
+
.assertThat(repository.queryWorkflowInstance(workflowInstanceId))
+ .matches(
+ workflowInstance ->
workflowInstance.getState() == WorkflowExecutionStatus.SUCCESS);
+ Assertions
+ .assertThat(repository.queryTaskInstance(workflow))
+ .satisfiesExactly(taskInstance -> {
+
assertThat(taskInstance.getState()).isEqualTo(TaskExecutionStatus.SUCCESS);
+ });
+ });
+
+ masterContainer.assertAllResourceReleased();
+ }
+
@Test
@DisplayName("Test start a workflow with one sub workflow task(A) success")
public void testStartWorkflow_with_subWorkflowTask_success() {
diff --git
a/dolphinscheduler-master/src/test/resources/it/failover/running_workflowInstance_with_one_running_fake_task_using_environment.yaml
b/dolphinscheduler-master/src/test/resources/it/failover/running_workflowInstance_with_one_running_fake_task_using_environment.yaml
new file mode 100644
index 0000000000..c34532994e
--- /dev/null
+++
b/dolphinscheduler-master/src/test/resources/it/failover/running_workflowInstance_with_one_running_fake_task_using_environment.yaml
@@ -0,0 +1,123 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+project:
+ name: MasterIntegrationTest
+ code: 1
+ description: This is a fake project
+ userId: 1
+ userName: admin
+ createTime: 2024-08-12 00:00:00
+ updateTime: 2021-08-12 00:00:00
+
+workflows:
+ - name: running_workflowInstance_with_one_running_fake_task_using_environment
+ code: 1
+ version: 1
+ projectCode: 1
+ description: This is a fake workflow with single task
+ releaseState: ONLINE
+ createTime: 2024-08-12 00:00:00
+ updateTime: 2021-08-12 00:00:00
+ userId: 1
+ executionType: PARALLEL
+
+workflowInstance:
+ id: 1
+ name:
running_workflowInstance_with_one_running_fake_task_using_environment-20240816071251690
+ workflowDefinitionCode: 1
+ workflowDefinitionVersion: 1
+ projectCode: 1
+ state: RUNNING_EXECUTION
+ recovery: NO
+ startTime: 2024-08-16 07:12:52
+ endTime: null
+ runTimes: 1
+ host: 127.0.0.1:5678
+ commandType: START_PROCESS
+ commandParam:
'{"commandType":"START_PROCESS","startNodes":[],"commandParams":[],"timeZone":"UTC"}'
+ taskDependType: TASK_POST
+ commandStartTime: 2024-08-16 07:12:52
+ isSubWorkflow: NO
+ executorId: 1
+ historyCmd: START_PROCESS
+ workerGroup: default
+ globalParams: '[]'
+ varPool: '[]'
+ dryRun: 0
+
+taskInstances:
+ - id: 1
+ name: A
+ taskType: LogicFakeTask
+ workflowInstanceId: 1
+ workflowInstanceName:
running_workflowInstance_with_one_running_fake_task_using_environment-20240816071251690
+ projectCode: 1
+ taskCode: 1
+ taskDefinitionVersion: 1
+ state: RUNNING_EXECUTION
+ firstSubmitTime: 2024-08-16 07:12:52
+ submitTime: 2024-08-16 07:12:57
+ startTime: 2024-08-16 07:12:57
+ endTime: 2024-08-16 07:12:57
+ retryTimes: 0
+ host: 127.0.0.1:1234
+ maxRetryTimes: 0
+ taskParams: '{"localParams":null,"varPool":[],"shellScript":"if [
\"${NAME}\" = \"Wenjun\" ]; then\n exit 0 \nelse\n exit 1\nfi"}'
+ flag: YES
+ retryInterval: 0
+ delayTime: 0
+ workerGroup: default
+ environmentCode: 1
+ executorId: 1
+ varPool: '[]'
+ taskExecuteType: BATCH
+
+tasks:
+ - name: A
+ code: 1
+ version: 1
+ projectCode: 1
+ userId: 1
+ taskType: LogicFakeTask
+ taskParams: '{"localParams":null,"varPool":[],"shellScript":"if [
\"${NAME}\" = \"Wenjun\" ]; then\n exit 0 \nelse\n exit 1\nfi"}'
+ workerGroup: default
+ environmentCode: 1
+ createTime: 2024-08-12 00:00:00
+ updateTime: 2021-08-12 00:00:00
+ taskExecuteType: BATCH
+
+taskRelations:
+ - projectCode: 1
+ workflowDefinitionCode: 1
+ workflowDefinitionVersion: 1
+ preTaskCode: 0
+ preTaskVersion: 0
+ postTaskCode: 1
+ postTaskVersion: 1
+ createTime: 2024-08-12 00:00:00
+ updateTime: 2024-08-12 00:00:00
+
+environments:
+ - id: 1
+ code: 1
+ name: MockEnv
+ config: 'export NAME=Wenjun'
+ description: 'test'
+ operator: 1
+ createTime: 2024-08-12 00:00:00
+ updateTime: 2021-08-12 00:00:00
diff --git
a/dolphinscheduler-master/src/test/resources/it/start/workflow_with_one_fake_task_using_environment_success.yaml
b/dolphinscheduler-master/src/test/resources/it/start/workflow_with_one_fake_task_using_environment_success.yaml
new file mode 100644
index 0000000000..0302d376b1
--- /dev/null
+++
b/dolphinscheduler-master/src/test/resources/it/start/workflow_with_one_fake_task_using_environment_success.yaml
@@ -0,0 +1,72 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+project:
+ name: MasterIntegrationTest
+ code: 1
+ description: This is a fake project
+ userId: 1
+ userName: admin
+ createTime: 2024-08-12 00:00:00
+ updateTime: 2021-08-12 00:00:00
+
+workflows:
+ - name: workflow_with_one_fake_task_using_environment_success
+ code: 1
+ version: 1
+ projectCode: 1
+ description: This is a fake workflow with single task
+ releaseState: ONLINE
+ createTime: 2024-08-12 00:00:00
+ updateTime: 2021-08-12 00:00:00
+ userId: 1
+ executionType: PARALLEL
+
+tasks:
+ - name: A
+ code: 1
+ version: 1
+ projectCode: 1
+ userId: 1
+ taskType: LogicFakeTask
+ taskParams: '{"localParams":null,"varPool":[],"shellScript":"if [
\"${NAME}\" = \"Wenjun\" ]; then\n exit 0 \nelse\n exit 1\nfi"}'
+ workerGroup: default
+ environmentCode: 1
+ createTime: 2024-08-12 00:00:00
+ updateTime: 2021-08-12 00:00:00
+ taskExecuteType: BATCH
+
+taskRelations:
+ - projectCode: 1
+ workflowDefinitionCode: 1
+ workflowDefinitionVersion: 1
+ preTaskCode: 0
+ preTaskVersion: 0
+ postTaskCode: 1
+ postTaskVersion: 1
+ createTime: 2024-08-12 00:00:00
+ updateTime: 2024-08-12 00:00:00
+
+environments:
+ - id: 1
+ code: 1
+ name: MockEnv
+ config: 'export NAME=Wenjun'
+ description: 'test'
+ operator: 1
+ createTime: 2024-08-12 00:00:00
+ updateTime: 2021-08-12 00:00:00
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 9024be12d5..c7ac6e7ef9 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
@@ -17,7 +17,6 @@
package org.apache.dolphinscheduler.plugin.task.api;
-import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy;
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
import
org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper;
@@ -113,9 +112,6 @@ public class TaskExecutionContext implements Serializable {
private String workerGroup;
- @Deprecated
- private TaskExecutionStatus currentExecutionStatus;
-
private ResourceParametersHelper resourceParametersHelper;
private long endTime;