--- title: "ADR 0083: Reconcile ordering and per-reconcile copies in the watcher" --- * Status: accepted * Code: [`pkg/reconciler/reconciler.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/reconciler/reconciler.go), [`pkg/reconciler/controller.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/reconciler/controller.go) ## Context Knative calls `ReconcileKind` concurrently for different PipelineRuns on one shared `Reconciler`. The informer cache can lag behind writes made by this controller, by Tekton, or by another controller outside PaC. A watcher restart re-enqueues every PipelineRun, so a completion event can be missed and must be recoverable from the next reconcile. ## Decision * `ReconcileKind` and `FinalizeKind` copy the `Reconciler` and its `params.Run` before doing anything, and `reconcileKind` re-scopes `eventEmitter` with the PipelineRun fields. Overlapping reconciles must not log under each other's fields. `reportFinalStatus` makes one more copy that carries the console parameters of the repository, so concurrent reconciles do not render URLs with another repository's parameters. * The PipelineRun is read fresh and the reconcile is skipped when its resourceVersion differs from the cached one. A `NotFound` on that read is handled as a deletion through `finalizeKind`. * A missing Repository drops its queue (`RemoveRepository`). A done PipelineRun then returns `nil`, because the admissions are gone and a retry cannot bring the Repository back; any other PipelineRun returns the error. * Admission is resumed (`AdmissionResume`) before the done early return, because an admission owner can be running or done while another member of its batch still needs recovery. * A done PipelineRun forgets its admission and calls `evaluateFollowUpsOf`. This is the recovery path for follow-ups whose completion event was missed (see [ADR 0058]({{< relref "0058-followup-dependency-graph.md" >}}) and [ADR 0079]({{< relref "0079-follow-up-cel-evaluation.md" >}})). * A GitHub App PipelineRun without a check run id is left alone until the id is annotated. * A run in `queued` state with `spec.status` pending goes to `queuePipelineRun`. A queued run whose status is no longer pending may have been cancelled and falls through so the cancellation is reported. * A run whose condition reason is `Running` but whose start was never reported to the provider gets `updatePipelineRunToInProgress`. See [ADR 0050]({{< relref "0050-queue-admission-lease-and-retry-reservation.md" >}}) for the queue side. ## Consequences * Every reconcile does an extra GET on the PipelineRun and may skip work on a stale cache; the next event retriggers it. * The pointer fields of `Reconciler` stay shared; only the copied struct values are isolated, so new mutable fields added to `Reconciler` or `params.Run` need the same treatment. * `enqueueQueuedPipelineRuns` re-enqueues the queued runs of a Repository when it changes, so a changed concurrency limit applies without an unrelated event. It does not cover a global Repository: waking every repository that merges from it would mean fanning out across all namespaces.