Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

Chapter 2. Understanding the Tekton Results retention policy


The Tekton Results Retention Policy Agent manages how long Tekton Results and Records are retained in the database before they are pruned. You can configure the retention behavior by using the tekton-results-config-results-retention-policy config map in the tekton-pipelines namespace.

The retention policy determines when and how old Tekton Results and Records are automatically deleted from the database. You can define global defaults as well as fine-grained rules based on namespaces, labels, annotations, or run statuses.

Use the following sample YAML configuration to define Tekton Results settings, including log retention policies, namespaces, and runtime options:

apiVersion: operator.tekton.dev/v1alpha1
kind: TektonConfig
metadata:
  labels:
    openshift-pipelines.tekton.dev/sa-created: "true"
    operator.tekton.dev/release-version: 1.21.0
  name: config
spec:
...
  result:
    disabled: false
    is_external_db: false
    log_level: debug
    loki_stack_name: logging-loki
    loki_stack_namespace: openshift-logging
    options:
      configMaps:
        tekton-results-config-results-retention-policy:
          data:
            defaultRetention: 30m
            policies: |
              - name: "prod-failed-retention"
                selector:
                  matchNamespaces:
                    - "prod-1"
                    - "prod-west"
                  matchStatuses:
                  - "Failed"
                  matchLabels:
                    "env": ["prod"]
                retention: "10m"
              - name: "all-prod-retention"
                selector:
                  matchNamespaces:
                    - "prod-1"
                    - "prod-west"
                retention: "3m"
            runAt: '*/1 * * * *'
          metadata:
            creationTimestamp: null
Copy to Clipboard Toggle word wrap

The following fields in the config map define the retention configuration:

Expand
FieldDescriptionDefault

runAt

Specifies when the pruning job runs. The value must use a cron schedule format.

"7 7 * * 7" (every Sunday at 7:07 a.m.)

defaultRetention

Specifies the fallback retention period for Results and Records when no specific policy matches. The value can be a number (in days) or a duration string such as 30d or 24h.

30d

maxRetention

(Deprecated). Used for backward compatibility if defaultRetention is not set. This field will be removed in a future release. This field functions in the same way as defaultRetention.

N/A

policies

Defines a list of fine-grained retention policies for more specific control, in order of precedence. Each policy includes a name, selector, and retention period. For Records and Results matched by a policy’s selector, the policy’s retention period overrides the defaultRetention.

None

2.1. Fine-grained retention policies

You can use the policies field to define rules that apply to specific Results. The policies are evaluated in order, and the first policy that matches is applied. If no policies match, the defaultRetention value is used.

Each policy includes the following fields:

Expand
FieldDescription

name

A descriptive name for the policy.

selector

Defines criteria for matching Results. All selector types use AND logic, meaning a Result must satisfy all specified conditions to match. You can omit a selector type to match all Results for that criterion.

matchNamespaces

A list of namespaces. The policy matches Results in any of the listed namespaces.

matchLabels

A map of label keys and possible values. A Result must have all listed label keys, and each value must match one of the values in the list.

matchAnnotations

A map of annotation keys and possible values. Works similarly to matchLabels.

matchStatuses

A list of final statuses such as Succeeded, Failed, Cancelled, Running, or Pending. The policy matches if the Result’s final status reason is in this list.

retention

The retention period for matching Results. The value can be a number (days) or a duration string such as 24h or 7d.

The following example shows a config map that defines multiple retention policies:

apiVersion: v1
kind: ConfigMap
metadata:
  name: tekton-results-config-results-retention-policy
  namespace: openshift-pipelines
data:
  runAt: "0 2 * * *"
  defaultRetention: "30d"
  policies: |
    - name: "retain-critical-failures-long-term"
      selector:
        matchNamespaces:
          - "production"
          - "prod-east"
        matchLabels:
          "criticality": ["high"]
        matchStatuses:
          - "Failed"
      retention: "180d"
    - name: "retain-annotated-for-debug"
      selector:
        matchAnnotations:
          "debug/retain": ["true"]
      retention: "14d"
    - name: "default-production-policy"
      selector:
        matchNamespaces:
          - "production"
          - "prod-east"
      retention: "60d"
    - name: "short-term-ci-retention"
      selector:
        matchNamespaces:
          - "ci"
      retention: "7d"
Copy to Clipboard Toggle word wrap

The following examples describe how the defined retention policies are applied to different Results based on their namespaces, labels, annotations, and statuses.

  • A failed Result in the production or prod-east namespace with the label criticality: high is retained for 180 days.
  • Any Result with the annotation debug/retain: "true" is retained for 14 days.
  • Results in the production or prod-east namespaces are retained for 60 days.
  • Results in the ci namespace are retained for 7 days.
  • All other Results that do not match any policy are retained for the default 30 days.
Nach oben
Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können. Entdecken Sie unsere neuesten Updates.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Theme

© 2025 Red Hat