Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDBBackup
metadata:
finalizers:
- delete-backup
name: backup-aws-s3
spec:
clusterName: some-name
Expand Down
4 changes: 4 additions & 0 deletions e2e-tests/demand-backup-eks-credentials/run
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ compare_mongo_cmd "find" "myApp:myPass@$cluster-0.$cluster.$namespace"
compare_mongo_cmd "find" "myApp:myPass@$cluster-1.$cluster.$namespace"
compare_mongo_cmd "find" "myApp:myPass@$cluster-2.$cluster.$namespace"

desc 'delete backup and check if it is removed from bucket -- aws-s3'
kubectl_bin delete psmdb-backup --all
check_backup_deletion "https://s3.amazonaws.com/${backup_dest_aws}" "aws-s3"

destroy $namespace

desc 'test passed'
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@ func (r *ReconcilePerconaServerMongoDBBackup) getPBMStorage(ctx context.Context,
}
return azure.New(azureConf, nil)
case cr.Status.S3 != nil:
if cr.Status.S3.CredentialsSecret == "" {
return nil, errors.New("no s3 credentials specified for the secret name")
}
s3Conf := s3.Conf{
Region: cr.Status.S3.Region,
EndpointURL: cr.Status.S3.EndpointURL,
Expand All @@ -271,9 +268,16 @@ func (r *ReconcilePerconaServerMongoDBBackup) getPBMStorage(ctx context.Context,
StorageClass: cr.Status.S3.StorageClass,
InsecureSkipTLSVerify: cr.Status.S3.InsecureSkipTLSVerify,
}
s3secret, err := secret(ctx, r.client, cr.Namespace, cr.Status.S3.CredentialsSecret)
if err != nil {
return nil, errors.Wrap(err, "getting s3 credentials secret name")

if cr.Status.S3.CredentialsSecret != "" {
s3secret, err := secret(ctx, r.client, cr.Namespace, cr.Status.S3.CredentialsSecret)
if err != nil {
return nil, errors.Wrap(err, "getting s3 credentials secret name")
}
s3Conf.Credentials = s3.Credentials{
AccessKeyID: string(s3secret.Data[backup.AWSAccessKeySecretKey]),
SecretAccessKey: string(s3secret.Data[backup.AWSSecretAccessKeySecretKey]),
}
}

if len(cr.Status.S3.ServerSideEncryption.SSECustomerAlgorithm) != 0 {
Expand Down Expand Up @@ -319,10 +323,6 @@ func (r *ReconcilePerconaServerMongoDBBackup) getPBMStorage(ctx context.Context,
}
}

s3Conf.Credentials = s3.Credentials{
AccessKeyID: string(s3secret.Data[backup.AWSAccessKeySecretKey]),
SecretAccessKey: string(s3secret.Data[backup.AWSSecretAccessKeySecretKey]),
}
return s3.New(s3Conf, nil)
default:
return nil, errors.New("no storage info in backup status")
Expand Down