Skip to content

Commit 7ae47cb

Browse files
authored
feat(cluster): expose stopDelay for fast scheduledbackups cleanup (#941)
The barman-plugin-scheduledbackups test intermittently fails with 'context deadline exceeded' during cleanup. The chart forces immediate: true on scheduled backups (templates/scheduled-backups.yaml), so a backup is still running when cleanup starts; Barman blocks instance shutdown until it completes, pushing teardown past the 5m cleanup budget on GitHub runners. Expose cluster.stopDelay in the chart (values + schema + template), mapping to the CNPG Cluster spec.stopDelay, which also sets the pod's terminationGracePeriodSeconds. The scheduledbackups test sets stopDelay: 30 so the instance is force-stopped promptly at teardown, interrupting the still-running backup. That's acceptable because this test only verifies a backup is started from the ScheduledBackup; backup success is covered by barman-plugin-backup-restore. Result: passes reliably and runs in ~75s (down from ~6m, previously timing out). Verified green in fork CI. This is the 'help it clean up faster' approach rather than raising the cleanup timeout. Supersedes #940. Supplements #924. Signed-off-by: Abdullah Alaqeel <abdullah.t.aqeel@gmail.com>
1 parent cc9d409 commit 7ae47cb

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

charts/cluster/templates/cluster.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ spec:
5656

5757
primaryUpdateMethod: {{ .Values.cluster.primaryUpdateMethod }}
5858
primaryUpdateStrategy: {{ .Values.cluster.primaryUpdateStrategy }}
59+
{{- with .Values.cluster.stopDelay }}
60+
stopDelay: {{ . }}
61+
{{- end }}
5962
logLevel: {{ .Values.cluster.logLevel }}
6063
{{- with .Values.cluster.certificates }}
6164
certificates:

charts/cluster/test/barman-plugin-scheduledbackups/01-scheduledbackups_cluster.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ type: postgresql
22
mode: standalone
33
cluster:
44
instances: 1
5+
# Use a short stopDelay so teardown is fast: the chart forces `immediate: true`
6+
# on scheduled backups, so a backup can still be running at cleanup time, and
7+
# Barman blocks instance shutdown until it completes. A low stopDelay caps the
8+
# pod's terminationGracePeriodSeconds, force-stopping the instance promptly.
9+
# This test only needs to observe that a backup was started.
10+
stopDelay: 30
511
storage:
612
size: 256Mi
713

charts/cluster/values.schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,12 @@
536536
"description": "Strategy to follow to upgrade the primary server during a rolling update procedure, after all replicas have been\nsuccessfully updated: it can be automated (unsupervised - default) or manual (supervised)",
537537
"type": "string"
538538
},
539+
"stopDelay": {
540+
"default": 1800,
541+
"description": "The time in seconds that is allowed for the instance to wait for the shutdown to complete before being forcefully\nterminated. Also sets the pod's terminationGracePeriodSeconds. Defaults to 1800 (30m) when unset.",
542+
"minimum": 1,
543+
"type": "integer"
544+
},
539545
"priorityClassName": {
540546
"default": "",
541547
"type": "string"

charts/cluster/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ cluster:
253253
# successfully updated: it can be automated (unsupervised - default) or manual (supervised)
254254
primaryUpdateStrategy: unsupervised
255255

256+
# -- The time in seconds that is allowed for the instance to wait for the shutdown
257+
# to complete before being forcefully terminated. Also sets the pod's terminationGracePeriodSeconds.
258+
# Defaults to 1800 (30m) when unset, per the operator default.
259+
# stopDelay: 1800
260+
256261
# -- The instances' log level, one of the following values: error, warning, info (default), debug, trace
257262
logLevel: "info"
258263

0 commit comments

Comments
 (0)