Skip to content

Commit dcd3e74

Browse files
committed
fix(keycloak): use 6-field CNPG cron and gate ScheduledBackup on destinationPath
Address review: CNPG ScheduledBackup.spec.schedule is a 6-field cron (leading seconds field), so the 5-field default was invalid — switch it to "0 0 2 * * *". Also gate the ScheduledBackup on backup.destinationPath to match db.yaml/backup-secret.yaml: schedule has a non-empty default, so the old guard rendered a ScheduledBackup against a Cluster with no object store whenever backups were enabled without a destinationPath. Assisted-By: Claude Signed-off-by: Andrei Kvapil <[email protected]>
1 parent e2094d0 commit dcd3e74

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎packages/system/keycloak/templates/backup.yaml‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{{/*
22
Scheduled S3 backup of the Keycloak CNPG database.
33

4-
Rendered only when both backup.enabled and backup.schedule are set. The
5-
Cluster's spec.backup.barmanObjectStore (see db.yaml) is what actually
6-
configures WAL archiving + the object store; this ScheduledBackup drives
7-
the recurring base backups. CNPG rejects an empty schedule, so the gate
8-
keeps invalid manifests off the cluster.
4+
Rendered only when backup.enabled, backup.destinationPath and
5+
backup.schedule are all set. The destinationPath gate must match db.yaml /
6+
backup-secret.yaml: without it the Cluster gets no spec.backup.barmanObjectStore,
7+
so a ScheduledBackup would target a Cluster with no object store and CNPG
8+
would perpetually fail it. CNPG also rejects an empty schedule.
9+
10+
NOTE: schedule is a 6-field cron (leading seconds field), not the 5-field
11+
Kubernetes CronJob format.
912
*/}}
10-
{{- if and .Values.backup.enabled .Values.backup.schedule }}
13+
{{- if and .Values.backup.enabled .Values.backup.destinationPath .Values.backup.schedule }}
1114
apiVersion: postgresql.cnpg.io/v1
1215
kind: ScheduledBackup
1316
metadata:

‎packages/system/keycloak/values.yaml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ extraVolumeMounts: []
9494
backup:
9595
# Enable S3 backups for keycloak-db.
9696
enabled: false
97-
# Cron schedule for recurring base backups (CNPG rejects an empty schedule).
98-
schedule: "0 2 * * *"
97+
# Cron schedule for recurring base backups. NOTE: CNPG ScheduledBackup uses a
98+
# 6-field cron (leading seconds field), not the 5-field Kubernetes format.
99+
schedule: "0 0 2 * * *"
99100
# Barman retention policy for stored backups.
100101
retentionPolicy: "30d"
101102
# Destination prefix, e.g. s3://bucket/keycloak-db/.

0 commit comments

Comments
 (0)