Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ private List<WorkflowTaskLineage> generateWorkflowLineageList(List<TaskDefinitio
.parseObject(taskDefinitionLog.getTaskParams(), DependentParameters.class)
.getDependence().getDependTaskList()) {
for (DependentItem dependentItem : dependentTaskModel.getDependItemList()) {
// A Dependent node cannot rely on itself workflow
if (dependentItem.getDefinitionCode() == workflowDefinitionCode) {
throw new ServiceException(Status.WORKFLOW_NODE_HAS_CYCLE);
}
Comment on lines +432 to +434
Copy link
Member

Choose a reason for hiding this comment

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

NIT: Maybe only check the dependeny type is DEPENDENT_ON_WORKFLOW? I am not clear if we shouldn't support dependent a task is in the same workflow.

And it's better to provide a method to check if the workflow exist cycle, since there are some extra case may stiil cause cycle, e.g. dependent a subworkflow node, the subworkflow contains a subworkflow task point to the parent workflow.

Suggested change
if (dependentItem.getDefinitionCode() == workflowDefinitionCode) {
throw new ServiceException(Status.WORKFLOW_NODE_HAS_CYCLE);
}
if (dependentItem.getDependentType() == DependentType.DEPENDENT_ON_WORKFLOW && dependentItem.getDefinitionCode() == workflowDefinitionCode) {
throw new ServiceException(Status.WORKFLOW_NODE_HAS_CYCLE);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your review—your suggestion makes sense.
However, I’m concerned that this change could break the existing design, since the current documentation explicitly permits this configuration of the dependent node. I’m not yet sure which behavior should be considered correct; please see my comment for details: #17873 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

@Mrhs121 So we should not do any restrictions here, as there may be scenarios where the current workflow depends on the previous day's operations? It might be better to let users control all of this themselves.

So this PR only fix the lineage cycle?

WorkflowTaskLineage workflowTaskLineage = new WorkflowTaskLineage();
workflowTaskLineage.setWorkflowDefinitionCode(workflowDefinitionCode);
workflowTaskLineage.setWorkflowDefinitionVersion(workflowDefinitionVersion);
Expand Down
Loading