Add validation to check Backup configuration is working

Problem to solve

Currently, when a Backup config is added, there's nothing to validate that the configuration is working, mainly the access to object storage. This is one of the main reasons for getting the backups to work.

Further details

When you create a SGCluster with a backup config, you can verify that your configuration is working by accessing the patroni container and execute the next commands:

Check READ permissions to the storage object:

bash-4.4$ exec-with-env backup -- wal-g st check read
INFO: 2024/10/22 11:10:57.830968 Read check OK

Check WRITE permissions to the storage object:

bash-4.4$ exec-with-env backup -- wal-g st check write
INFO: 2024/10/22 11:19:20.365984 Write check OK

If something is wrong with the access you could get an error like:

ERROR: 2024/10/22 11:11:14.860194 failed to write to the storage: failed to upload 'sgbackups.stackgres.io/stackgres/my-db/2024-10-21-18-11-48/15/ea581c0b201ac0e889d4243778658d44' to bucket 'backup-stackgres-euc1-prod': AccessDenied: User: arn:aws:iam::000000:user/my-db-stackgres-backup-prod is not authorized to perform: s3:PutObject on resource: "arn:aws:s3:::my-db-backup-stackgres-euc1-prod/sgbackups.stackgres.io/stackgres/my-db/2024-10-21-18-11-48/15/ea581c0000000000" because no identity-based policy allows the s3:PutObject action
	status code: 403, request id: 1K5XXXXXXXXX, host id: QEfLnNWGaQrzpujFmfBLP1vzwr6eYLDx5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/cQ/7/5/B

Proposal

  • Add a validation when the backup config is added and report to the user if everything is OK or if there any issue with the configuration.

Acceptance Criteria

  • A message indicating the test results or errors in the configuration.