feat(logical-backup): configurable job history limits and TTL#3091
Open
yajo wants to merge 1 commit into
Open
Conversation
Adds three new configuration options for logical backup cronjobs: - logical_backup_successful_jobs_history_limit (default: 3) - logical_backup_failed_jobs_history_limit (default: 3) - logical_backup_ttl_seconds_after_finished (default: 86400) These options control how many completed/failed backup jobs are retained by Kubernetes and when finished jobs are automatically deleted. This prevents accumulation of old backup jobs and pods in namespaces with many PostgreSQL clusters. Also updates the CronJob comparison logic to detect changes in these new fields and trigger reconciliation when needed. Closes zalando#1092
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds three new configuration options for logical backup cronjobs:
logical_backup_successful_jobs_history_limit(default: 3)logical_backup_failed_jobs_history_limit(default: 3)logical_backup_ttl_seconds_after_finished(default: 86400)Problem
Currently, the postgres-operator does not configure any of these fields on the logical backup CronJob. This means:
ttlSecondsAfterFinishedis set, so completed/failed backup Jobs and their Pods accumulate indefinitely.This fixes #1092.
Solution
Files changed
pkg/util/config/config.go— new config fieldspkg/apis/acid.zalan.do/v1/operator_configuration_type.go— CRD struct fieldspkg/controller/operator_config.go— wiring from CRD to internal configpkg/cluster/k8sres.go— CronJob generationpkg/cluster/cluster.go— CronJob comparisonpkg/cluster/k8sres_test.go— generation testspkg/cluster/cluster_test.go— comparison testscharts/postgres-operator/values.yaml— Helm valuescharts/postgres-operator/crds/operatorconfigurations.yaml— CRD schemaDisclaimer
I am no Go programmer. This has been AI-assisted by kimi-k2.6.
@moduon