--- title: "ADR 0001: Webhook reconciliation is singleton-keyed" --- * Status: accepted * Code: [`pkg/webhook/controller.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/webhook/controller.go), [`pkg/webhook/reconciler.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/webhook/reconciler.go) ## Context The admission webhook controller (knative sharedmain) reconciles one object: the `ValidatingWebhookConfiguration` named in the reconciler key. Three things can make it wrong on the cluster: * the `ValidatingWebhookConfiguration` itself is edited or recreated * the certificate secret is rotated, and `ClientConfig.CABundle` in the configuration becomes stale * this replica becomes the leader and has to bring the configuration in line The knative reconcile loop is keyed: an informer event hands `Reconcile` a string key. That key is not used here, because the object being reconciled is not the object that changed. A secret rotation does not name the webhook configuration. ## Decision Every event from the three sources is enqueued, with the event payload ignored (`controller.HandleAll(c.Enqueue)`), and `Reconcile` always reads the singleton identified by `ac.key`. * the `ValidatingWebhookConfiguration` informer is filtered by name * the certificate secret informer is filtered by name and `SYSTEM_NAMESPACE` * `LeaderAwareFuncs.PromoteFunc` enqueues the singleton key on leadership acquisition `Reconcile` rebuilds the whole webhook configuration from scratch (rules, CA bundle, service path), deep copies the live object, and writes it only when `kmp.SafeEqual` reports a difference. ## Consequences * Reconciliation is idempotent and costs one full state comparison per event, not a targeted patch. * Any new trigger must enqueue the singleton key. A handler that enqueues the changed object's key still works, but only by accident. * Adding a second `ValidatingWebhookConfiguration` to this controller would require keying by name, because the current key is hard-coded to one object.