-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Fix condition task will cause workflow instance failed #16152
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,10 +25,8 @@ | |
import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; | ||
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; | ||
import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; | ||
import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; | ||
import org.apache.dolphinscheduler.plugin.task.api.parameters.ConditionsParameters; | ||
import org.apache.dolphinscheduler.plugin.task.api.utils.DependentUtils; | ||
import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager; | ||
import org.apache.dolphinscheduler.server.master.exception.LogicTaskInitializeException; | ||
import org.apache.dolphinscheduler.server.master.runner.task.BaseSyncLogicTask; | ||
|
||
import java.util.List; | ||
|
@@ -40,37 +38,34 @@ | |
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class ConditionLogicTask extends BaseSyncLogicTask<DependentParameters> { | ||
public class ConditionLogicTask extends BaseSyncLogicTask<ConditionsParameters> { | ||
|
||
public static final String TASK_TYPE = "CONDITIONS"; | ||
|
||
private final TaskInstanceDao taskInstanceDao; | ||
private final ProcessInstanceDao workflowInstanceDao; | ||
|
||
private final TaskInstance taskInstance; | ||
|
||
public ConditionLogicTask(TaskExecutionContext taskExecutionContext, | ||
ProcessInstanceExecCacheManager processInstanceExecCacheManager, | ||
TaskInstance taskInstance, | ||
TaskInstanceDao taskInstanceDao, | ||
ProcessInstanceDao workflowInstanceDao) throws LogicTaskInitializeException { | ||
ProcessInstanceDao workflowInstanceDao) { | ||
// todo: we need to change the parameter in front-end, so that we can directly use json to parse | ||
super(taskExecutionContext, | ||
processInstanceExecCacheManager.getByProcessInstanceId(taskExecutionContext.getProcessInstanceId()) | ||
.getTaskInstance(taskExecutionContext.getTaskInstanceId()) | ||
.orElseThrow(() -> new LogicTaskInitializeException( | ||
"Cannot find the task instance in workflow execute runnable")) | ||
.getDependency()); | ||
// todo:check the parameters, why we don't use conditionTask? taskInstance.getDependency(); | ||
super(taskExecutionContext, taskInstance.getConditionsParameters()); | ||
this.taskInstanceDao = taskInstanceDao; | ||
this.workflowInstanceDao = workflowInstanceDao; | ||
this.taskInstance = taskInstance; | ||
} | ||
|
||
@Override | ||
public void handle() { | ||
// calculate the conditionResult | ||
DependResult conditionResult = calculateConditionResult(); | ||
TaskExecutionStatus taskExecutionStatus = | ||
(conditionResult == DependResult.SUCCESS) ? TaskExecutionStatus.SUCCESS : TaskExecutionStatus.FAILURE; | ||
log.info("The condition result is {}, task instance statue will be: {}", conditionResult, taskExecutionStatus); | ||
taskExecutionContext.setCurrentExecutionStatus(taskExecutionStatus); | ||
log.info("The condition result is {}", conditionResult); | ||
taskParameters.setConditionSuccess(conditionResult == DependResult.SUCCESS); | ||
taskInstance.setConditionsParameters(taskParameters); | ||
taskExecutionContext.setCurrentExecutionStatus(TaskExecutionStatus.SUCCESS); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to update the docs too. see https://dolphinscheduler.apache.org/zh-cn/docs/3.2.1/guide/task/conditions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find the doc is correct, we don't need to update it. |
||
} | ||
|
||
private DependResult calculateConditionResult() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍