このコンテンツは選択した言語では利用できません。
Chapter 2. Understanding the Tekton Results retention policy
The Tekton Results Retention Policy Agent manages how long the database retains Tekton Results and Records before pruning them. 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 and 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
The following fields in the config map define the retention configuration:
| Field | Description | Default |
|---|---|---|
|
| Specifies when the pruning job runs. The value must use a cron schedule format. |
|
|
|
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 |
|
|
|
(Deprecated). Used for backward compatibility if | N/A |
|
|
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 | None |
2.1. Fine-grained retention policies リンクのコピーリンクがクリップボードにコピーされました!
You can use the policies field to define rules that apply to specific Results. Tekton Results evaluates the policies in order, and applies the first matching policy. If no policies match, Tekton Results uses the defaultRetention value.
Each policy includes the following fields:
| Field | Description |
|---|---|
|
| A descriptive name for the policy. |
|
|
Defines criteria for matching Results. All selector types use |
|
| A list of namespaces. The policy matches Results in any of the listed namespaces. |
|
| 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. |
|
|
A map of annotation keys and possible values. Works similarly to |
|
|
A list of final statuses such as |
|
|
The retention period for matching Results. The value can be a number (days) or a duration string such as |
The following example shows a config map that defines many 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"
The following examples describe how Tekton Results applies the defined retention policies to different Results based on their namespaces, labels, annotations, and statuses.
-
Tekton Results retains a failed Result in the
productionorprod-eastnamespace with the labelcriticality: highfor 180 days. -
Tekton Results retains any Result with the annotation
debug/retain: "true"for 14 days. -
Tekton Results retains Results in the
productionorprod-eastnamespaces for 60 days. -
Tekton Results retains Results in the
cinamespace for 7 days. - Tekton Results retains all other Results that do not match any policy for the default 30 days.