conductor icon indicating copy to clipboard operation
conductor copied to clipboard

[FEATURE]: when a workflow is removed, not all of its children are removed.

Open mspasiano opened this issue 1 year ago • 4 comments

Please read our contributor guide before creating an issue.
Also consider discussing your idea on the discussion forum first.

Describe the Feature Request

When a workflow is removed, not all of its children are removed.

Describe Preferred Solution

You could include in the removal of a workflow the search for children via parent_workflow_id to then be able to remove them together with the connected tasks.

mspasiano avatar Sep 30 '24 07:09 mspasiano

Hi @mspasiano can you provide a sample workflow and steps to reproduce?

v1r3n avatar Oct 05 '24 05:10 v1r3n

For example, at this point you could search for all workflows that have the incoming workflowId as parent_workflow_id and delete them by calling the same method

mspasiano avatar Oct 07 '24 16:10 mspasiano

Inspecting the code a bit, the solution could be to store the parent_workflow_id information on the indexes and in case these are active use it to get all the child workflows. Could this be a viable solution?

mspasiano avatar Oct 08 '24 14:10 mspasiano

I tried changing the strategy and inserting the removal of the workflow when the task responsible for starting it is removed:

if (Optional.ofNullable(task) 
.map(TaskModel::getTaskType) 
.filter( 
s -> 
s.equalsIgnoreCase(TaskType.TASK_TYPE_START_WORKFLOW) 
|| s.equalsIgnoreCase(TaskType.TASK_TYPE_SUB_WORKFLOW)) 
.isPresent()) { 
Optional.ofNullable(task.getOutputData()) 
.map( 
stringObjectMap -> 
Optional.ofNullable(stringObjectMap.get("workflowId")) 
.orElseGet(task::getSubWorkflowId)) 
.map(String::valueOf) 
.ifPresent( 
workflowId -> { 
try {
logger.trace("Try to delete workflow {}", workflowId);
removeWorkflow(workflowId);
} catch (NotFoundException _ex) {
logger.trace(_ex.getMessage());
}
});
}

It works, but removal is very slow. Any suggestions?

mspasiano avatar Aug 01 '25 17:08 mspasiano