Retention Policy Configuration
Tekton Results retention policy provides automated cleanup for both database records and archived logs in S3-compatible storage systems. The retention agent periodically removes expired results and their associated log payloads according to configurable time-based policies.
Configuration
Retention policies are configured through the TektonConfig custom resource using the spec.result.options field to specify ConfigMap overrides:
Configuration Parameters
-
defaultRetention: Specifies the number of days to retain results before automatic deletion. After this period elapses, both the database records and associated log payloads in S3 storage will be cleaned up. -
runAt: Cron expression defining when the retention agent runs."0 2 * * *"- Daily at 2:00 AM"0 2 * * 0"- Weekly on Sundays at 2:00 AM"0 2 1 * *"- Monthly on the 1st at 2:00 AM
Apply Configuration
Apply the TektonConfig configuration:
Example Output:
Wait for the retention agent to restart:
Example Output:
Verify the configuration is active:
Example Output:
Important Note
Important: The unified cleanup functionality (deleting both database records and S3 log payloads together) is a enhancement (patch-based) and is not currently available in community Tekton Results. The community version only removes database records but leaves log payloads in S3 storage, which can lead to unbounded storage growth.
Check TektonConfig retention configuration:
Example Output (abbreviated):
Check retention agent logs:
Example Output:
Verification
To quickly verify that the retention policy is functioning as expected, follow these steps:
-
Create test results/logs: Generate some Tekton PipelineRuns or TaskRuns that will produce results and logs in your Tekton Results database.
-
Verify initial state: Check that the results and logs are present in the database and S3 storage (if applicable).
-
Modify retention policy for testing: Temporarily set a very short retention period and a specific cron schedule for testing purposes (e.g., execute once at current time + 10 minutes).
-
Apply modified configuration: Apply the temporary test configuration and wait for the retention agent to restart.
-
Monitor retention agent logs: Watch the retention agent logs to confirm cleanup operations are occurring.
-
Verify cleanup occurred: After the retention schedule executes, verify that the older results and logs have been removed.
-
Revert to production settings: Once verified, revert the retention policy to your intended production values.
Warning: Be careful when setting very short retention periods as this will delete results immediately. Ensure you are using a test environment for verification.