Backup fails when storage credentials or parameters contain special characters

Description

Backups fail if storage credentials or parameters like destination, containerName, or endpointUrl contain special characters.

The reason for this is build/run-backup.sh. In this script, we send a json request, in which we insert environment variables without escaping them. This way, if a variable contained a character like " or \n it could break a json format or provide an invalid value to a parameter.

Steps to reproduce:
1. change e2e-tests/conf/minio-secret to

apiVersion: v1 kind: Secret metadata: name: minio-secret stringData:   AWS_ACCESS_KEY_ID: some-access-key   AWS_SECRET_ACCESS_KEY: some"\n,"-secret-key

2. launch demand-backup test (it will fail on step 3-create-backup-minio)
3. kubectl logs demand-backup-mysql-1 xtrabackup output:

1.672852827191469e+09 ERROR sidecar failed to unmarshal backup config {"namespace": "kuttl-test-modest-liger", "name": "demand-backup-minio", "namespace": "kuttl-test-modest-liger", "name": "demand-backup-minio", "namespace": "kuttl-test-modest-liger", "name": "demand-backup-minio", "namespace": "kuttl-test-modest-liger", "name": "demand-backup-minio", "error": "invalid character '\\\\' after object key:value pair"} main.createBackupHandler /go/src/github.com/percona/percona-server-mysql-operator/cmd/sidecar/main.go:265 main.backupHandler /go/src/github.com/percona/percona-server-mysql-operator/cmd/sidecar/main.go:106 net/http.HandlerFunc.ServeHTTP /usr/local/go/src/net/http/server.go:2109 net/http.(*ServeMux).ServeHTTP /usr/local/go/src/net/http/server.go:2487 net/http.serverHandler.ServeHTTP /usr/local/go/src/net/http/server.go:2947 net/http.(*conn).serve /usr/local/go/src/net/http/server.go:1991

 

Environment

None

Activity

Show:

Slava Sarzhan March 20, 2023 at 10:46 AM

The issue was fixed.

Done

Details

Assignee

Reporter

Needs QA

Yes

Fix versions

Affects versions

Priority

Smart Checklist

Created January 4, 2023 at 5:23 PM
Updated March 30, 2023 at 4:29 PM
Resolved March 28, 2023 at 10:07 AM