Skip to content

Commit

Permalink
Merge pull request #242 from vshn/fix/redis_backup
Browse files Browse the repository at this point in the history
Fix backups if Redis TLS is disabled
  • Loading branch information
TheBigLee authored Oct 14, 2024
2 parents 64e3bad + 59116dd commit 88cb04c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/comp-functions/functions/vshnredis/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ 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))
}

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{
Expand Down
6 changes: 5 additions & 1 deletion pkg/comp-functions/functions/vshnredis/script/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 88cb04c

Please sign in to comment.