diff --git a/cmd/backup/config.go b/cmd/backup/config.go index 6dec1259..e076c51d 100644 --- a/cmd/backup/config.go +++ b/cmd/backup/config.go @@ -4,8 +4,8 @@ package main import ( - "os" "fmt" + "os" "regexp" "time" ) @@ -62,14 +62,14 @@ type Config struct { } func (c *Config) resolveSecret(envVar string, secretPath string) (string, error) { - if secretPath != "" { - data, err := os.ReadFile(secretPath) - if err != nil { - return "", fmt.Errorf("resolveSecret: error reading secret path: %w", err) - } - return string(data), nil + if secretPath == "" { + return envVar, nil + } + data, err := os.ReadFile(secretPath) + if err != nil { + return "", fmt.Errorf("resolveSecret: error reading secret path: %w", err) } - return envVar, nil + return string(data), nil } type RegexpDecoder struct { diff --git a/internal/storage/s3/s3.go b/internal/storage/s3/s3.go index bb2394d8..97feb80b 100644 --- a/internal/storage/s3/s3.go +++ b/internal/storage/s3/s3.go @@ -100,8 +100,10 @@ func (b *s3Storage) Copy(file string) error { ContentType: "application/tar+gzip", StorageClass: b.storageClass, }); err != nil { - errResp := minio.ToErrorResponse(err) - return fmt.Errorf("(*s3Storage).Copy: error uploading backup to remote storage: [Message]: '%s', [Code]: %s, [StatusCode]: %d", errResp.Message, errResp.Code, errResp.StatusCode) + if errResp := minio.ToErrorResponse(err); errResp.Message != "" { + return fmt.Errorf("(*s3Storage).Copy: error uploading backup to remote storage: [Message]: '%s', [Code]: %s, [StatusCode]: %d", errResp.Message, errResp.Code, errResp.StatusCode) + } + return fmt.Errorf("(*s3Storage).Copy: error uploading backup to remote storage: %w", err) } b.Log(storage.LogLevelInfo, b.Name(), "Uploaded a copy of backup `%s` to bucket `%s`.", file, b.bucket) diff --git a/test/secret/docker-compose.yml b/test/secrets/docker-compose.yml similarity index 76% rename from test/secret/docker-compose.yml rename to test/secrets/docker-compose.yml index 433b1e38..afb9bc45 100644 --- a/test/secret/docker-compose.yml +++ b/test/secrets/docker-compose.yml @@ -4,31 +4,19 @@ version: '3.8' services: - minio_setup: - image: alpine:latest - deploy: - restart_policy: - condition: none - volumes: - - backup_data:/data - command: mkdir -p /data/backup - minio: - image: minio/minio:RELEASE.2021-12-20T22-07-16Z + image: minio/minio:RELEASE.2020-08-04T23-10-51Z deploy: restart_policy: condition: on-failure environment: - MINIO_ROOT_USER_FILE: /run/secrets/minio_root_user - MINIO_ROOT_PASSWORD_FILE: /run/secrets/minio_root_password - command: minio server /data + MINIO_ROOT_USER: test + MINIO_ROOT_PASSWORD: test + MINIO_ACCESS_KEY: test + MINIO_SECRET_KEY: GMusLtUmILge2by+z890kQ + entrypoint: /bin/ash -c 'mkdir -p /data/backup && minio server /data' volumes: - backup_data:/data - secrets: - - minio_root_user - - minio_root_password - depends_on: - - minio_setup backup: image: offen/docker-volume-backup:${TEST_VERSION:-canary} @@ -81,6 +69,7 @@ volumes: backup_data: name: backup_data pg_data: + name: pg_data secrets: minio_root_user: diff --git a/test/secret/run.sh b/test/secrets/run.sh similarity index 96% rename from test/secret/run.sh rename to test/secrets/run.sh index c5e32bc8..cf3af927 100755 --- a/test/secret/run.sh +++ b/test/secrets/run.sh @@ -41,4 +41,4 @@ docker swarm leave --force sleep 10 docker volume rm backup_data -docker volume rm test_stack_pg_data +docker volume rm pg_data diff --git a/test/swarm/docker-compose.yml b/test/swarm/docker-compose.yml index 3ba64ab0..7b04be3c 100644 --- a/test/swarm/docker-compose.yml +++ b/test/swarm/docker-compose.yml @@ -66,3 +66,4 @@ volumes: backup_data: name: backup_data pg_data: + name: pg_data diff --git a/test/swarm/run.sh b/test/swarm/run.sh index d96fb109..0ec2cc24 100755 --- a/test/swarm/run.sh +++ b/test/swarm/run.sh @@ -34,4 +34,4 @@ docker swarm leave --force sleep 10 docker volume rm backup_data -docker volume rm test_stack_pg_data +docker volume rm pg_data