tektoncd/pipeline

perf: strip ManagedFields from PipelineRun and TaskRun informer caches

开放

#9,573 创建于 2026年3月15日

 (0 条评论) (1 个反应) (1 位负责人)Go (1,943 个派生)auto 404
good first issuekind/feature

仓库指标

星标
 (9,013 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Feature request

Add SetTransform on PipelineRun and TaskRun shared informers to strip metadata.managedFields on cache insert.

Kubernetes objects carry managedFields which can be 30-70% of the object's serialized size. The Tekton controller never reads managedFields, but every DeepCopy (3-4 per reconcile cycle via the Knative reconciler framework) copies them in full.

Where to add the transform

Implementation

stripManagedFields := func(obj interface{}) (interface{}, error) {
    if accessor, ok := obj.(metav1.ObjectMetaAccessor); ok {
        accessor.GetObjectMeta().SetManagedFields(nil)
    }
    return obj, nil
}
if err := pipelineRunInformer.Informer().SetTransform(stripManagedFields); err != nil {
    logging.FromContext(ctx).Warnf("Failed to set informer transform: %v", err)
}

Use case

  • Reduces memory footprint of the controller's informer caches
  • Reduces CPU time spent on DeepCopy operations during reconciliation
  • This pattern is established in the Kubernetes ecosystem (e.g., kube-controller-manager added ManagedFields stripping in k8s 1.27)
  • SetTransform is available in client-go's shared_informer.go

贡献者指南