Run state machine callbacks when using AbortPipelinesService
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem
In !56126 (merged) we improved the performance of killing running pipelines when a user is blocked. We did that by updating directly the pipelines/stages/jobs statuses to failed with a failure_reason.
However, by doing this bulk update we are ignoring some callbacks that are part of the state machine.
Details
When we look at both jobs and pipelines state machines there are a few things that we may need to consider doing as a cleanup:
-
set
finished_atwhen pipeline completes - pipeline's persistent ref deleted
- update auto-devops pipelines counter - this might be fine to skip perhaps
- update pipeline ref status
-
set
finished_atwhen job completes - drop deployment associated to the job when a job is failed
- Release resource groups when job completes
The challenge here is to avoid having duplication between this service and the state machines. The main difference is that we should have a single-mode state machine callbacks (for when a job/pipeline instance is updated) and bulk-mode state machine callbacks when we bulk update issues.
Also, one thing to keep in mind for the follow-up is that depending on the use case we might optimize the workflow by skipping some callbacks since they may not be relevant. For example, updating finished_at may be ok when blocking a user, since the data should be consistent from other user's point of view (e.g. other project members). However, it's not needed when deleting a project since the data will be dropped anyway.