Skip to content
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

Merged
merged 2 commits into from
Jun 19, 2024

Conversation

ruanwenjun
Copy link
Member

@ruanwenjun ruanwenjun commented Jun 13, 2024

Purpose of the pull request

close #16150

Brief change log

  • Put task into error map once a task is failure
  • Refactor the condition task check logic.

Verify this pull request

This pull request is code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(or)

If your pull request contain incompatible change, you should also add it to docs/docs/en/guide/upgrede/incompatible.md

Comment on lines +2016 to +2021
/**
* Whether the task instance need to put into {@link #errorTaskMap}.
* Only the task instance is failed or killed, and it is parent of condition task.
* Then it should be put into {@link #errorTaskMap}.
* <p> Once a task instance is put into {@link #errorTaskMap}, it will be thought as failed and make the workflow be failed.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

log.info("The condition result is {}", conditionResult);
taskParameters.setConditionSuccess(conditionResult == DependResult.SUCCESS);
taskInstance.setConditionsParameters(taskParameters);
taskExecutionContext.setCurrentExecutionStatus(TaskExecutionStatus.SUCCESS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Comment on lines -309 to -330
Map<String, Object> taskParamsMap = new HashMap<>();
taskParamsMap.put(Constants.SWITCH_RESULT, "");
taskInstance.setTaskParams(JSONUtils.toJsonString(taskParamsMap));
taskInstance.setState(TaskExecutionStatus.FAILURE);
completeTaskList.put(3L, taskInstance);
postNodes = DagHelper.parsePostNodes(null, skipNodeList, dag, completeTaskList);
Assertions.assertEquals(1, postNodes.size());
Assertions.assertTrue(postNodes.contains(6L));
Assertions.assertEquals(2, skipNodeList.size());
Assertions.assertTrue(skipNodeList.containsKey(5L));
Assertions.assertTrue(skipNodeList.containsKey(7L));

// dag: 1-2-3-5-7 4-3-6
// 3-if , complete:1/2/3/4
// 1.failure:3 expect post:6 skip:5/7
dag = generateDag2();
skipNodeList.clear();
completeTaskList.clear();
taskInstance.setSwitchDependency(getSwitchNode());
completeTaskList.put(1L, taskInstance);
postNodes = DagHelper.parsePostNodes(1L, skipNodeList, dag, completeTaskList);
Assertions.assertEquals(1, postNodes.size());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should keep the switch UT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have switch UT case, and it's better to split the switch case from condition case. we need to make the case is small enough to maintain.

@codecov-commenter
Copy link

codecov-commenter commented Jun 15, 2024

Codecov Report

Attention: Patch coverage is 10.90909% with 49 lines in your changes missing coverage. Please review.

Project coverage is 40.98%. Comparing base (edeb1b2) to head (f0af190).

Current head f0af190 differs from pull request most recent head aa34769

Please upload reports for the commit aa34769 to get more accurate results.

Files Patch % Lines
...ache/dolphinscheduler/dao/entity/TaskInstance.java 0.00% 21 Missing ⚠️
.../server/master/runner/WorkflowExecuteRunnable.java 0.00% 13 Missing ⚠️
...ster/runner/task/condition/ConditionLogicTask.java 0.00% 6 Missing ⚠️
...ask/condition/ConditionLogicTaskPluginFactory.java 0.00% 5 Missing ⚠️
...ache/dolphinscheduler/service/utils/DagHelper.java 55.55% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                dev   #16152      +/-   ##
============================================
- Coverage     41.07%   40.98%   -0.09%     
+ Complexity     5155     5146       -9     
============================================
  Files          1399     1399              
  Lines         44856    44844      -12     
  Branches       4756     4735      -21     
============================================
- Hits          18423    18381      -42     
- Misses        24628    24653      +25     
- Partials       1805     1810       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@SbloodyS SbloodyS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@SbloodyS SbloodyS added this to the 3.2.2 milestone Jun 16, 2024
@ruanwenjun ruanwenjun requested a review from rickchengx June 16, 2024 13:57
Copy link
Contributor

@rickchengx rickchengx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot added the test label Jun 18, 2024
@ruanwenjun ruanwenjun changed the title Fix condition task will cause workflow instance failed [Bug] Fix condition task will cause workflow instance failed Jun 18, 2024
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
11.5% Coverage on New Code (required ≥ 60%)

See analysis details on SonarCloud

@ruanwenjun ruanwenjun merged commit 5df4b1c into apache:dev Jun 19, 2024
62 of 64 checks passed
@ruanwenjun ruanwenjun deleted the upstream-dev branch June 19, 2024 03:28
ruanwenjun added a commit to ruanwenjun/dolphinscheduler that referenced this pull request Jun 19, 2024
ruanwenjun added a commit that referenced this pull request Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Workflow status is success when task execute failed
5 participants