From 59116dd98f731531ff9a45f166a836b805573dda Mon Sep 17 00:00:00 2001 From: Nicolas Bigler Date: Mon, 14 Oct 2024 09:56:22 +0200 Subject: [PATCH] Fix backups if Redis TLS is disabled Signed-off-by: Nicolas Bigler --- pkg/comp-functions/functions/vshnredis/backup.go | 4 ++-- pkg/comp-functions/functions/vshnredis/script/backup.sh | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/comp-functions/functions/vshnredis/backup.go b/pkg/comp-functions/functions/vshnredis/backup.go index 9a578a1d14..393b61957c 100644 --- a/pkg/comp-functions/functions/vshnredis/backup.go +++ b/pkg/comp-functions/functions/vshnredis/backup.go @@ -45,7 +45,7 @@ func AddBackup(ctx context.Context, comp *vshnv1.VSHNRedis, svc *runtime.Service } l.Info("Creating backup config map") - err = createScriptCM(ctx, comp, svc) + err = createScriptCM(comp, svc) if err != nil { return runtime.NewFatalResult(fmt.Errorf("cannot create backup config map: %w", err)) } @@ -53,7 +53,7 @@ func AddBackup(ctx context.Context, comp *vshnv1.VSHNRedis, svc *runtime.Service return nil } -func createScriptCM(ctx context.Context, comp *vshnv1.VSHNRedis, svc *runtime.ServiceRuntime) error { +func createScriptCM(comp *vshnv1.VSHNRedis, svc *runtime.ServiceRuntime) error { cm := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ diff --git a/pkg/comp-functions/functions/vshnredis/script/backup.sh b/pkg/comp-functions/functions/vshnredis/script/backup.sh index d7470bd1cc..2ee5181ecf 100644 --- a/pkg/comp-functions/functions/vshnredis/script/backup.sh +++ b/pkg/comp-functions/functions/vshnredis/script/backup.sh @@ -5,7 +5,11 @@ # it will also backup that one. redis_cmd() { - redis-cli -a "${REDIS_PASSWORD}" --cacert "${REDIS_TLS_CA_FILE}" --cert "${REDIS_TLS_CERT_FILE}" --key "${REDIS_TLS_KEY_FILE}" --tls "$@" + if [ -z "$REDIS_TLS_CERT_FILE" ]; then + redis-cli -a "${REDIS_PASSWORD}" "$@" + else + redis-cli -a "${REDIS_PASSWORD}" --cacert "${REDIS_TLS_CA_FILE}" --cert "${REDIS_TLS_CERT_FILE}" --key "${REDIS_TLS_KEY_FILE}" --tls "$@" + fi } rewrite_percentage=$(redis_cmd --raw CONFIG GET auto-aof-rewrite-percentage | tail -n 1) 1>&2