-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Remove tasks from Elasticsearch when workflow is removed #3300
Remove tasks from Elasticsearch when workflow is removed #3300
Conversation
* Add removeTask method for IndexDAO Implement removeTask and asyncRemoveTask methods to the IndexDAO interface. Implemented in ElasticSearchDAOV6, ElasticSearchRestDAOV6, and NoopIndexDAO. * Implement removal of tasks for removeWorkflow - Update ExecutionDAOFacade#removeWorkflow with two new parameters: removeTasks and archiveTasks - Added ExecutionDAOFacade#removeTaskIndex - Added methods updateTask and asyncUpdateWorkflow to IndexDAO - Added methods updateTask and asyncUpdateWorkflow to ElasticSearchDAOV6 and ElasticSearchRestDAOV6 * Add tests for removing workflow through /workflow/remove - Introduced tests for WorkflowServiceTest - Introduced tests for WorkflowResourceTest - Introduced test for ExecutionDAOFacadeTest - Introduced test for QueueResilienceSpec.groovy * Update Javadoc to include task archival when workflow archived and removeTasks true
Once reviewed I will resolve the merge conflicts. |
es6-persistence/src/main/java/com/netflix/conductor/es6/dao/index/ElasticSearchRestDAOV6.java
Outdated
Show resolved
Hide resolved
- Now tasks are search and associated with workflows through a search query directly embedded rather than constructed - If a task can not be removed it will error and return - Monitors are updated automatically - Updated TestElasticSearchRestDAOV6 and TestElasticSearchDAOV6
I have gone ahead and resolved the merge conflicts @jxu-nflx @apanicker-nflx @ghoshabhi |
@RemcoBuddelmeijer Thanks for creating the PR and 💯 on adding a wide slew of tests. While I understand the reasoning for adding a flag |
core/src/main/java/com/netflix/conductor/core/dal/ExecutionDAOFacade.java
Show resolved
Hide resolved
@apanicker-nflx Okay that sounds good. I'll go ahead and remove it and trust on people not relying on undefined behaviour. |
Currently ExecutionDAOFacade would call removeTask double the amount of times, this has been fixed. Now the only bug still present is that tasks are not terminated once removed and with that the index may also not be removed.
@apanicker-nflx After updating the QueueResilienceSpec test to also include archiving workflows it notices that the workflow or the tasks associated with the workflow are not terminated in the same execution as this is done through the ExecutionService. At least for now I will push the change removing the archival test of QueueResiliencySpec. I have pushed this as part of this PR to show the execution of both scenarios. |
try { | ||
removeWorkflowIndex(workflow, archiveWorkflow); | ||
} catch (JsonProcessingException e) { | ||
throw new TransientException("Workflow can not be serialized to json", e); | ||
} | ||
|
||
executionDAO.removeWorkflow(workflowId); | ||
tasks.forEach( |
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.
Why loop through the tasks twice? A regular for loop might be easier to read here, and couldn't you do both operations through a single loop of the tasks?
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.
Personally I found it more readable and easier to have two separate loops with separate error handling where queue removal can be controlled separately from index removal.
When it comes to a traditional for loop: I wanted to keep in line with the style of the file. But this can always be changed.
Either way since it’s unnecessary to loop over something twice and now that the order of method has been changed allowing the loops to be merged, I’ll go ahead and merge the loops.
The only other thing I would call out is that the Community Version will need to be updated as well for the V7 ElasticSearch IndexDAO. So whoever releases this fix (thanks for fixing btw!!!!!), will need to be aware when they bump the version over in Community @apanicker-nflx |
@james-deee I can always merge this logic into the community edition as well. |
@apanicker-nflx sorry for the ping, just wanted to see the status of this PR. Thanks! |
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.
LGTM
@ghoshabhi and @apanicker-nflx when is an ETA that we can expect this to get merged and for a new release of Conudctor to go out? I know there is also some batch polling that was added to the Java client that we'd also like to take advantage of. Thanks! |
@ghoshabhi or @apanicker-nflx sorry to ping again, just wanted to see if there was an update on this. Thanks! |
Pull Request type
./gradlew generateLock saveLock
to refresh dependencies)NOTE: Please remember to run
./gradlew spotlessApply
to fix any format violations.Changes in this PR
Implement removal of tasks when calling /workflow/remove
Written tests for the new behaviour
Updated Javadocs where necessary to reflect on the new changes
Describe the new behavior from this PR, and why it's needed
Issue #1505
Tasks were not removed from Elasticsearch once the workflow was removed. This is necessary to not leave hanging objects in Elasticsearch that are not connected to any existing instance of a workflow. This change allows you to specify to also remove the tasks.
Alternatives considered
None
Additional notes
Options for removing tasks and archiving tasks have both been considered. In the final draft only the option to remove tasks was introduced. This to keep the changes clear and communicate to the user that tasks are removed now. On top of this all of this was done as it's unknown if the users are using this undefined behaviour of tasks not being removed. This was later on removed in the PR as it can be trusted that users do not rely on unidentified behaviour.
Right now to minimize the impact of the change the option to toggle on removing tasks or not is present. Only methods being called by the WorkflowResource class for workflow removal allows you to delete tasks, any other class such as WorkflowServiceImpl does not implement this yet. This can be done in a future PR.