Documentation
¶
Overview ¶
Package cachetransform provides cache transform functions for reducing memory usage in the Tekton Pipeline controller informer caches.
Transform functions are applied to objects before they are stored in the informer cache, allowing us to strip large, unnecessary fields while preserving the data needed for reconciliation. They only affect the controller's in-memory informer cache; the full objects always remain in etcd.
The transforms are wired into the TaskRun and PipelineRun controllers via Setup (see setup.go), which calls SharedIndexInformer.SetTransform.
Scope: these transforms currently strip only universally-safe metadata fields (managedFields and the kubectl last-applied-configuration annotation). Stripping status fields from completed objects was intentionally deferred: several of those fields (TaskRun status.taskSpec/steps/sidecars and PipelineRun status.pipelineSpec) are still read from cache after completion (by the parent PipelineRun, by retryTaskRun, by stopSidecars, and by upcoming Pipelines-in-Pipelines result propagation).
DEVELOPER WARNING: If you add new reconciliation logic that reads a field from cached objects (via listers), you MUST verify that field is not stripped by these transforms. Fields stripped from cached objects will be nil/empty even though they exist in etcd. If you need a stripped field, either:
- Use the Kubernetes API client directly to fetch the full object from etcd, or
- Update the transform functions to preserve the field (consider memory impact).
See docs/developers/controller-logic.md for more details.
Index ¶
Constants ¶
const ( // LastAppliedConfigAnnotation is the annotation used by kubectl to store // the last applied configuration. This can be very large and is not needed // in the cache. LastAppliedConfigAnnotation = "kubectl.kubernetes.io/last-applied-configuration" )
Variables ¶
This section is empty.
Functions ¶
func ForPod ¶
func ForPod(obj interface{}) (interface{}, error)
ForPod is a cache.TransformFunc that strips unnecessary metadata fields from cached Pods to reduce memory usage in the TaskRun controller.
Only universally-safe metadata is stripped; the Pod spec and status are left intact. Tombstone objects (DeletedFinalStateUnknown) are unwrapped, transformed, and rewrapped.
func ForTektonResource ¶
func ForTektonResource(obj interface{}) (interface{}, error)
ForTektonResource is a cache.TransformFunc that strips unnecessary metadata fields from cached PipelineRuns, TaskRuns and CustomRuns to reduce memory usage.
Objects that are not PipelineRuns, TaskRuns or CustomRuns are passed through unchanged. Tombstone objects (DeletedFinalStateUnknown) are unwrapped, transformed, and rewrapped.
func Setup ¶
func Setup(ctx context.Context, informer cache.SharedIndexInformer, transformFn cache.TransformFunc)
Setup applies a cache transform to an informer if the feature is enabled.
It must be called before the informer starts (i.e. in the controller's NewController constructor). SetTransform returns an error only if the informer has already started, which would be a programming error, so we fail fast. When called multiple times on the same informer the last call wins; this is harmless because all callers use the same transform function.
Types ¶
This section is empty.