--- title: "ADR 0002: Clear OwnerReferences on the webhook configuration before updating" --- * Status: accepted * Code: [`pkg/webhook/reconciler.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/webhook/reconciler.go), `reconcileValidatingWebhook` ## Context A `ValidatingWebhookConfiguration` that carries an `OwnerReference` is garbage collected along with its owner. If the owner is deleted while the webhook configuration still exists, the API server removes the admission configuration and `Repository` validation silently stops running. [knative/serving#5845](https://github.com/knative/serving/issues/5845) is the upstream report of exactly that failure, where the webhook configuration disappeared. Owner references can also be left behind by a previous installation or by a manifest that was applied by hand, so a controller that copies the live object and only overwrites rules and certificates keeps reintroducing the reference. ## Decision The `OwnerReferences` field of the deep copy is set to `nil` on every reconcile, before the comparison and the update, so any reference present on the live object is removed on the next reconcile, including ones this controller never wrote. ## Consequences * The webhook configuration has no owner, so it is not deleted implicitly. Its lifecycle is owned by whoever applies it (the operator), which must delete it explicitly. * The clearing is unconditional rather than diff-driven: it happens on every reconcile, and it is idempotent because a nil list compares equal to a nil list. * If ownership by a controller is ever wanted, this line has to be removed together with a decision about which object owns the configuration, not merged with new rules.