×

Stale TaskRun and PipelineRun objects and their executed instances occupy physical resources that can be used for the active runs. To prevent this waste, Red Hat OpenShift Pipelines provides annotations that cluster administrators can use to automatically prune the unused objects and their instances in various namespaces.

  • Starting with Red Hat OpenShift Pipelines 1.6, auto-pruning is enabled by default.

  • Configuring automatic pruning by specifying annotations affects the entire namespace. You cannot selectively auto-prune individual task runs and pipeline runs in a namespace.

Annotations for automatically pruning task runs and pipeline runs

To automatically prune task runs and pipeline runs in a namespace, you can set the following annotations:

  • operator.tekton.dev/prune.schedule: If the value of this annotation is different from the value specified in the TektonConfig custom resource definition, a new cron job in that namespace is created.

  • operator.tekton.dev/prune.skip: When set to true, the namespace for which it is configured is not pruned.

  • operator.tekton.dev/prune.resources: This annotation accepts a comma-separated list of resources. To prune a single resource such as a pipeline run, set this annotation to "pipelinerun". To prune multiple resources, such as task run and pipeline run, set this annotation to "taskrun, pipelinerun".

  • operator.tekton.dev/prune.keep: Use this annotation to retain a resource without pruning.

  • operator.tekton.dev/prune.keep-since: Use this annotation to retain resources based on their age. The value for this annotation must be equal to the age of the resource in minutes. For example, to retain resources which were created not more than five days ago, set keep-since to 7200.

    The keep and keep-since annotations are mutually exclusive. For any resource, you must configure only one of them.

  • operator.tekton.dev/prune.strategy: Set the value of this annotation to either keep or keep-since.

For example, consider the following annotations that retain all task runs and pipeline runs created in the last five days, and deletes the older resources:

Example of auto-pruning annotations
...
  annotations:
    operator.tekton.dev/prune.skip: false
    operator.tekton.dev/prune.resources: "taskrun, pipelinerun"
    operator.tekton.dev/prune.keep-since: 7200
...

Additional resources