--- title: "ADR 0084: Confirming a start and treating gone runs as terminal" --- * Status: accepted * Code: [`pkg/reconciler/reconciler.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/reconciler/reconciler.go), [`pkg/reconciler/queue_pipelineruns.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/reconciler/queue_pipelineruns.go) ## Context A queued PipelineRun is started by one merge patch that sets state `started`, `scm-reporting-plr-started`, and clears `spec.status`. The patch can fail without telling the caller whether Kubernetes applied it, and the run can be cancelled, finished or replaced by a same-named run while the patch is in flight. The queue reservation ([ADR 0050]({{< relref "0050-queue-admission-lease-and-retry-reservation.md" >}})) must be kept for an uncertain start and released for a run that can never start. ## Decision * For `started` the patch carries `resourceVersion` and `uid`, so a delayed start fails against cancellation, completion or replacement. A conflict is not retried with the same resourceVersion; the caller reads the run back. Other states go through `action.PatchPipelineRun`. * `spec.status` is only cleared when it is still pending: some Tekton versions reject any spec update once a run has started, even a no-op one. * After a patch error the run is read back. `NotFound`, a different UID or `noLongerStartable` gives `errPipelineRunGone`. A read error or `startConfirmed` being false gives `ErrPipelineRunNotStarted`, wrapped with both errors, because neither the patch error nor a pending read rules out an in-flight conditional write. * `startConfirmed` requires non-pending spec, state `started` and the reporting annotation: a run Tekton already started proves nothing about the annotations this patch carries. * `startQueueCandidate` maps `errPipelineRunGone` to `StartGone`, `ErrPipelineRunNotStarted` to no outcome (the owner may resume its slot), and anything else to `StartSucceeded`. A gone candidate is removed from the ordered list and admission continues with the next one. * In `AdmissionPromotion` a failure to report after a confirmed start is logged, not returned, because it is not unfinished queue work. A failed status report in `updatePipelineRunToInProgress` is likewise logged: the run is already started and the final status will be posted when it completes. * In `reconcileKind`, `errPipelineRunGone` returns `nil`. A cancelled or gracefully stopped run keeps the `Running` reason, and no retry can change that condition. ## Consequences * An unconfirmed start keeps its slot until a resume succeeds, so a stuck write can hold concurrency capacity. * A provider shows the run as queued until the next successful report if the in-progress status fails.