conductor: fix on-error cleanup skipped when source task cancelled-after-completion#443
Merged
Merged
Conversation
petrutlucian94
approved these changes
May 27, 2026
Dany9966
reviewed
May 27, 2026
…ter-completion When concurrently deploying resources on the source (deploy_source) and on the target (deploy_target), if deploy_target fails while deploy_source is still running, the conductor marks deploy_source as `CANCELLING` and sends it a cancel signal. If deploy_source finishes its work before the signal kills it, `task_completed()` is sent for a task in the `CANCELLING` state. The conductor saves the result (so source_resources, including the resource ID is saved in the DB) and marks the task `CANCELED_AFTER_COMPLETION`. The on-error cleanup scheduling logic in _advance_execution_state checks: ``` elif TASK_STATUS_COMPLETED in non_error_parents.values(): ``` `CANCELED_AFTER_COMPLETION` != `COMPLETED`, so the check is False. `DELETE_TRANSFER_SOURCE_RESOURCES` is unscheduled and the source resource is leaked. Adding `CLEANUP_TASK_TRIGGER_STATUSES`, covering both `COMPLETED` and `CANCELED_AFTER_COMPLETION`, since both mean the task ran to completion and may have created resources that need cleaning up. Use that constant in the on-error scheduling check. Adding assertions in `coriolis/tests/integration/test_failure_recovery.py`, that check in the DB that `DELETE_TRANSFER_SOURCE_RESOURCES` / `DELETE_TRANSFER_TARGET_RESOURCES` reached a completed status, and that the source /target resources were zeroed out in the action info.
0921431 to
34480ba
Compare
Dany9966
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When concurrently deploying resources on the source (deploy_source) and on the target (deploy_target), if deploy_target fails while deploy_source is still running, the conductor marks deploy_source as
CANCELLINGand sends it a cancel signal.If deploy_source finishes its work before the signal kills it,
task_completed()is sent for a task in theCANCELLINGstate. The conductor saves the result (so source_resources, including the resource ID is saved in the DB) and marks the taskCANCELED_AFTER_COMPLETION.The on-error cleanup scheduling logic in _advance_execution_state checks:
CANCELED_AFTER_COMPLETION!=COMPLETED, so the check is False.DELETE_TRANSFER_SOURCE_RESOURCESis unscheduled and the source resource is leaked.Adding
CLEANUP_TASK_TRIGGER_STATUSES, covering bothCOMPLETEDandCANCELED_AFTER_COMPLETION, since both mean the task ran to completion and may have created resources that need cleaning up. Use that constant in the on-error scheduling check.Adding assertions in
coriolis/tests/integration/test_failure_recovery.py, that check in the DB thatDELETE_TRANSFER_SOURCE_RESOURCES/DELETE_TRANSFER_TARGET_RESOURCESreached a completed status, and that the source /target resources were zeroed out in the action info.