From 25d1eedc59bf4775fb7df4d2b1fde49ad9d0a56d Mon Sep 17 00:00:00 2001 From: Sophie Huang Date: Tue, 25 Jan 2022 20:58:27 +0000 Subject: [PATCH] Postgresql: Enhance postgresql backup Pick up the helm-toolkit DB backup enhancement in postgresql to add capability to retry uploading backup to remote server. Change-Id: I041d83211f08a8d0c9c22a66e16e6b7652bfc7d9 --- postgresql/Chart.yaml | 2 +- postgresql/templates/bin/_backup_postgresql.sh.tpl | 3 +++ postgresql/templates/cron-job-backup-postgres.yaml | 6 ++++++ postgresql/templates/secret-backup-restore.yaml | 3 +++ postgresql/values.yaml | 4 ++++ releasenotes/notes/postgresql.yaml | 1 + 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/postgresql/Chart.yaml b/postgresql/Chart.yaml index d3cd5d6e8..1f7b5ce26 100644 --- a/postgresql/Chart.yaml +++ b/postgresql/Chart.yaml @@ -15,7 +15,7 @@ apiVersion: v1 appVersion: v9.6 description: OpenStack-Helm PostgreSQL name: postgresql -version: 0.1.11 +version: 0.1.12 home: https://www.postgresql.org sources: - https://github.com/postgres/postgres diff --git a/postgresql/templates/bin/_backup_postgresql.sh.tpl b/postgresql/templates/bin/_backup_postgresql.sh.tpl index cae73978c..12ebdd7a9 100755 --- a/postgresql/templates/bin/_backup_postgresql.sh.tpl +++ b/postgresql/templates/bin/_backup_postgresql.sh.tpl @@ -32,6 +32,9 @@ export DB_NAMESPACE=${POSTGRESQL_POD_NAMESPACE} export DB_NAME="postgres" export LOCAL_DAYS_TO_KEEP=$POSTGRESQL_LOCAL_BACKUP_DAYS_TO_KEEP export REMOTE_DAYS_TO_KEEP=$POSTGRESQL_REMOTE_BACKUP_DAYS_TO_KEEP +export REMOTE_BACKUP_RETRIES=${NUMBER_OF_RETRIES_SEND_BACKUP_TO_REMOTE} +export MIN_DELAY_SEND_REMOTE=${MIN_DELAY_SEND_BACKUP_TO_REMOTE} +export MAX_DELAY_SEND_REMOTE=${MAX_DELAY_SEND_BACKUP_TO_REMOTE} export ARCHIVE_DIR=${POSTGRESQL_BACKUP_BASE_DIR}/db/${DB_NAMESPACE}/${DB_NAME}/archive # This function dumps all database files to the $TMP_DIR that is being diff --git a/postgresql/templates/cron-job-backup-postgres.yaml b/postgresql/templates/cron-job-backup-postgres.yaml index 98fe9fa8b..f2f59e217 100644 --- a/postgresql/templates/cron-job-backup-postgres.yaml +++ b/postgresql/templates/cron-job-backup-postgres.yaml @@ -110,6 +110,12 @@ spec: value: "{{ .Values.conf.backup.remote_backup.container_name }}" - name: STORAGE_POLICY value: "{{ .Values.conf.backup.remote_backup.storage_policy }}" + - name: NUMBER_OF_RETRIES_SEND_BACKUP_TO_REMOTE + value: {{ .Values.conf.backup.remote_backup.number_of_retries | quote }} + - name: MIN_DELAY_SEND_BACKUP_TO_REMOTE + value: {{ .Values.conf.backup.remote_backup.delay_range.min | quote }} + - name: MAX_DELAY_SEND_BACKUP_TO_REMOTE + value: {{ .Values.conf.backup.remote_backup.delay_range.max | quote }} {{- with $env := dict "ksUserSecret" $envAll.Values.secrets.identity.postgresql }} {{- include "helm-toolkit.snippets.keystone_openrc_env_vars" $env | indent 16 }} {{- end }} diff --git a/postgresql/templates/secret-backup-restore.yaml b/postgresql/templates/secret-backup-restore.yaml index d63612686..b9e2f298e 100644 --- a/postgresql/templates/secret-backup-restore.yaml +++ b/postgresql/templates/secret-backup-restore.yaml @@ -23,5 +23,8 @@ data: REMOTE_BACKUP_CONTAINER: {{ $envAll.Values.conf.backup.remote_backup.container_name | b64enc }} REMOTE_BACKUP_DAYS_TO_KEEP: {{ $envAll.Values.conf.backup.remote_backup.days_to_keep | quote | b64enc }} REMOTE_BACKUP_STORAGE_POLICY: {{ $envAll.Values.conf.backup.remote_backup.storage_policy | b64enc }} + REMOTE_BACKUP_RETRIES: {{ $envAll.Values.conf.backup.remote_backup.number_of_retries | quote | b64enc }} + REMOTE_BACKUP_SEND_DELAY_MIN: {{ $envAll.Values.conf.backup.remote_backup.delay_range.min | quote | b64enc }} + REMOTE_BACKUP_SEND_DELAY_MAX: {{ $envAll.Values.conf.backup.remote_backup.delay_range.max | quote | b64enc }} ... {{- end }} diff --git a/postgresql/values.yaml b/postgresql/values.yaml index 57feee5be..cf26283ac 100644 --- a/postgresql/values.yaml +++ b/postgresql/values.yaml @@ -328,6 +328,10 @@ conf: container_name: postgresql days_to_keep: 14 storage_policy: default-placement + number_of_retries: 5 + delay_range: + min: 30 + max: 60 exporter: queries: diff --git a/releasenotes/notes/postgresql.yaml b/releasenotes/notes/postgresql.yaml index d7903cc1f..b990adfc6 100644 --- a/releasenotes/notes/postgresql.yaml +++ b/releasenotes/notes/postgresql.yaml @@ -12,4 +12,5 @@ postgresql: - 0.1.9 Use full image ref for docker official images - 0.1.10 Helm 3 - Fix Job labels - 0.1.11 Update htk requirements + - 0.1.12 Enhance postgresql backup ...