Repository navigation
fix: the nightly database backup only uploads into a bucket owned by the S3 keys' account - #711
Merged
Merged
Conversation
…the S3 keys' account For a remote S3 endpoint the backup now lists the account's buckets first and refuses to upload when the configured bucket is not among them. On AWS every call also passes --expected-bucket-owner with the account id from STS. Keys that cannot list buckets still upload, with a note. The in-cluster store is unchanged.
…akes --expected-bucket-owner where aws s3 cp and rm do not aws s3 cp and aws s3 rm reject --expected-bucket-owner, so every AWS backup failed. On AWS the owner is now checked with s3api head-bucket before the upload, s3 cp runs without the option and keeps multipart, and the prune lists and deletes through s3api with the owner. The AWS endpoint match ignores case, a scheme and a trailing slash, and covers amazonaws.com.cn. A 401 on the bucket listing counts as keys that cannot list buckets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hardens the nightly database backup so it only uploads to a remote bucket that belongs to the account the panel's S3 keys are in.
*.amazonaws.comand*.amazonaws.com.cn, ignoring case, scheme and trailing slash), it runss3api head-bucket --expected-bucket-ownerwith the keys' 12-digit account id from STS and stops if that fails. The prune'slist-objects-v2anddelete-objectpass the same owner.aws s3 cpdoesn't take the option, so the upload itself runs without it and still handles multipart.s3api delete-object.tests/scripts/postgres_backup_test.shruns the CronJob's script against stubbedaws/pg_dump/zip. The stub rejects options the real CLI rejects. The test is wired into the panel-scripts workflow (includingbase/backups/**).