--- title: "ADR 0037: Informer caches strip fields the watcher does not read" --- * Status: accepted * Code: [`pkg/informer/transform/transform.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/informer/transform/transform.go), [`pkg/reconciler/controller.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/reconciler/controller.go) ## Context The watcher reconciler keeps `Repository` and `PipelineRun` objects in shared informer caches. `PipelineRun` objects are large: `status.pipelineSpec` embeds the full pipeline definition, plus `childReferences`, provenance and span context. `Repository` objects carry `managedFields` and annotations such as `kubectl.kubernetes.io/last-applied-configuration`. The benchmark file in [`pkg/informer/transform`](https://github.com/tektoncd/pipelines-as-code/tree/main/pkg/informer/transform) sizes these fields for realistic objects. ## Decision `pkg/reconciler/controller.go` installs `RepositoryForCache` and `PipelineRunForCache` with `SetTransform` on the two informers, so objects are trimmed before they enter the cache. * `RepositoryForCache` sets `ManagedFields` and `Annotations` to nil. * `PipelineRunForCache` sets `ManagedFields` to nil, clears `Spec.PipelineRef`, `PipelineSpec`, `Params`, `Workspaces`, `TaskRunSpecs`, `TaskRunTemplate` and `Timeouts`, and clears `Status.PipelineSpec`, `ChildReferences`, `Provenance` and `SpanContext`. What survives is ObjectMeta (name, namespace, labels, annotations, finalizers, deletionTimestamp), `Spec.Status` (pending check), `Status.Conditions`, `StartTime` and `CompletionTime`. * Anything other than the expected pointer type passes through unchanged. * A `cache.DeletedFinalStateUnknown` tombstone is unwrapped, transformed and re-wrapped with the same key. On error the original object is returned with a nil error, so a transform failure degrades to caching the full object instead of breaking the informer. ## Consequences * Reconciler code that reads a cached object through a lister sees nil or empty values for every stripped field, even though the field exists in etcd. New reconciliation logic that needs one of them must either keep the field in the transform or fetch the full object from the API server. `postFinalStatus` and `GetStatusFromTaskStatusOrFromAsking` take the second route. * Cached objects are mutated in place, not copied. * The list of preserved fields is maintained by hand and is only as accurate as the code that reads the cache.