--- title: "ADR 0093: Cancellation covers pending follow-ups before their dependencies" --- * Status: accepted * Code: [`pkg/pipelineascode/cancel_pipelineruns.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/pipelineascode/cancel_pipelineruns.go) * See: [ADR 0058]({{< relref "0058-followup-dependency-graph.md" >}}) ## Context Cancel-in-progress, closed pull requests and `/cancel` all patch running PipelineRuns. A follow-up that is still waiting has no run, only an entry stored on a dependency run, and the watcher creates it when its dependencies finish. ## Decision * Cancel-in-progress is on when the ConfigMap says so for the event type (pull request or push) and a PipelineRun `cancel-in-progress` annotation overrides it either way. It returns an error when the repository has a concurrency limit greater than zero. * On a closed pull request the label selector adds `cancel-in-progress notin (false)` when the global setting is on, and `cancel-in-progress=true` when it is off. * The original PipelineRun name is read from labels, not annotations, because the runs are selected by it through the Kubernetes API. * A run is superseded only when its source branch matches the event's head branch (both without `refs/heads/`) and it is not the new run. The listing holds runs of other branches too. * Follow-up runs that depend on a superseded run's definition in the superseded run's group are superseded as well, even if that run is finished, otherwise they would create the rest of the chain. Pending follow-ups depending on it are cancelled even when the run holding them is not superseded. * `cancelPipelineRuns` cancels pending follow-ups first, then patches the runs: they have no run for the cancel patch to reach, and cancelling a dependency first would let the watcher create them. * `/cancel ` searches every listed run for follow-ups, since the waiting follow-up is stored on a run of another definition; `cancelFollowUps` filters on the name. A closed pull request also searches every run, while cancel-in-progress restricts the search to the superseded and downstream runs. ## Consequences * A group other than the current `groupID` is the only one touched by cascading.