--- title: "ADR 0090: Creating the follow-up run is idempotent and reports like startPR" --- * Status: accepted * Code: [`pkg/reconciler/followup.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/reconciler/followup.go) ## Context Several reconciles can evaluate the same follow-up at once, a `/cancel` can land while the run is being created, and the run must then behave like any other run of the repository. ## Decision * The run name is the follow-up ID, not generated. An existing run with that name, or `AlreadyExists` on creation, means another reconcile won: the follow-up is consumed as created. * The auto created git auth secret is deleted on any creation error, as `startPR` does. Its name is generated per resolution, so the winner of a concurrent creation uses a secret of its own. The ownerRef is set after creation, and a failure there is only logged. * The spec status is reset, then the state annotation is set at creation: the watcher only reconciles runs carrying it, so a lost start patch cannot orphan the run. The run is created pending with the `queued` state and an execution order under a concurrency limit, `started` otherwise. * After creation the run itself decides what is reported, not the repository settings: a pending run (concurrency limit, or an external mutating webhook) is reported queued and labelled queued, otherwise it is reported in progress. A failing report is logged and does not stop the consume. * A cancel consumes the follow-up before it looks for its run and can miss a run still being created. After creation the stored state is read again and a cancelled follow-up gets its run cancelled. * The repository is merged with the global one, as the queue admission does, so an inherited concurrency limit applies. ## Consequences * The creation logic duplicates part of `startPR`, and the two have to be kept in step by hand. * A started run whose start was not reported is retried by its own reconcile.