--- title: "ADR 0009: Patching PipelineRuns with doubled conflict retries" --- * Status: accepted * Code: [`pkg/action/patch.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/action/patch.go), `PatchPipelineRun` * Ticket: [SRVKP-3134](https://issues.redhat.com/browse/SRVKP-3134) ## Context PAC annotates a `PipelineRun` several times while it runs (state, reason, completion time). The Tekton controller writes the same object, so a merge patch regularly loses the optimistic-concurrency race and comes back as a conflict. Retrying is correct here: each patch carries an idempotent merge patch, and the retry re-applies it to the freshly read object. The controller writes far more often than a typical client, and [SRVKP-3134](https://issues.redhat.com/browse/SRVKP-3134) reports patch conflicts exhausting the default retry budget, which surfaces as annotations missing from completed runs. ## Decision `PatchPipelineRun` doubles every parameter of `retry.DefaultRetry` (steps, duration, factor, jitter) and runs the patch inside `retry.RetryOnConflict`. When the retries are exhausted, it returns the original `PipelineRun` together with the error, not a nil object: the caller still has a valid object to report against, and it decides whether the failure is fatal for the reconcile or only for the annotation. ## Consequences * A conflicting patch can now occupy a reconcile for noticeably longer before giving up (a few seconds rather than a few hundred milliseconds). * The doubling is applied to the package default rather than configured, so tuning it means editing the function. Avoiding a magic constant would require a config surface nobody has asked for. * Callers must check the error before using the returned object, because a failed patch returns the pre-patch version.