-
Notifications
You must be signed in to change notification settings - Fork 933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Storage: Add support for storage bucket backup (from Incus) #13924
base: main
Are you sure you want to change the base?
Conversation
08a58ba
to
8fdf38f
Compare
Heads up @mionaalex - the "Documentation" label was applied to this issue. |
19cae2b
to
8b2a40c
Compare
This comment was marked as outdated.
This comment was marked as outdated.
8b2a40c
to
94eb9bf
Compare
eb04463
to
ccbbddd
Compare
d70a96f
to
b1894d6
Compare
please can you rebase |
4a4b0ad
to
a58a3e1
Compare
@tomponline I've isolated the storage bucket backups functionality as discussed, though I'm seeing the pipeline fail due to large lxc binary size: I'm not entirely sure what to do about this. |
@simondeziel can point u in right direction to update this (if the growth is expected, but it sounds like you may have increasex the lxc command unexpectedly via import changes) |
client/lxd_storage_buckets.go
Outdated
return nil, err | ||
} | ||
|
||
op, _, err := r.queryOperation("POST", fmt.Sprintf("/storage-pools/%s/buckets/%s/backups", url.PathEscape(poolName), url.PathEscape(bucketName)), backup, "", true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use string concatenation ("/storage-pools"+url.PathEscape(poolName)+"/buckets/"+...
) instead of fmt.Sprintf()
.
Same applies to each of the new funcs.
lxd/project/project.go
Outdated
@@ -123,6 +123,11 @@ func StorageVolumeProjectFromRecord(p *api.Project, volumeType int) string { | |||
return api.ProjectDefaultName | |||
} | |||
|
|||
// StorageBucket adds the "<project>_prefix" to the storage bucket name. Even if the project name is "default". | |||
func StorageBucket(projectName string, storageBucketName string) string { | |||
return fmt.Sprintf("%s%s%s", projectName, separator, storageBucketName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Sprintf("%s%s%s", projectName, separator, storageBucketName) | |
return projectName + separator + storageBucketName |
lxd/storage/s3/transfer_manager.go
Outdated
} | ||
|
||
fi := instancewriter.FileInfo{ | ||
FileName: fmt.Sprintf("backup/bucket/%s", objectInfo.Key), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FileName: fmt.Sprintf("backup/bucket/%s", objectInfo.Key), | |
FileName: "backup/bucket/" + objectInfo.Key, |
lxd/storage/s3/transfer_manager.go
Outdated
func (t TransferManager) getEndpoint() string { | ||
hostname := t.s3URL.Hostname() | ||
if validate.IsNetworkAddressV6(hostname) == nil { | ||
hostname = fmt.Sprintf("[%s]", hostname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hostname = fmt.Sprintf("[%s]", hostname) | |
hostname = "[" + hostname + "]" |
lxd/storage/s3/transfer_manager.go
Outdated
hostname = fmt.Sprintf("[%s]", hostname) | ||
} | ||
|
||
return fmt.Sprintf("%s:%s", hostname, t.s3URL.Port()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Sprintf("%s:%s", hostname, t.s3URL.Port()) | |
return hostname + ":" + t.s3URL.Port() |
lxd/storage/s3/transfer_manager.go
Outdated
DisableCompression: true, | ||
TLSClientConfig: &tls.Config{ | ||
InsecureSkipVerify: true, | ||
MinVersion: tls.VersionTLS12, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno if that'd be applicable here but we have some helper function to get a TLS/HTTPS enabled connection where it uses some LXD specific tweaks like requiring TLS 1.3+.
lxd/storage_buckets.go
Outdated
defer revert.Fail() | ||
|
||
// Create temporary file to store uploaded backup data. | ||
backupFile, err := os.CreateTemp(shared.VarPath("backups"), fmt.Sprintf("%s_", backup.WorkingDirPrefix)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backupFile, err := os.CreateTemp(shared.VarPath("backups"), fmt.Sprintf("%s_", backup.WorkingDirPrefix)) | |
backupFile, err := os.CreateTemp(shared.VarPath("backups"), backup.WorkingDirPrefix+"_") |
@@ -186,3 +186,107 @@ EOF | |||
|
|||
delete_object_storage_pool "${poolName}" | |||
} | |||
|
|||
test_storage_bucket_export() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first glance, that's a rather extensive test script, thanks for that!!
test/suites/storage_buckets.sh
Outdated
@@ -186,3 +186,107 @@ EOF | |||
|
|||
delete_object_storage_pool "${poolName}" | |||
} | |||
|
|||
test_storage_bucket_export() { | |||
# shellcheck disable=2039,3043 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabling those shouldn't be needed AFAIK.
15746576 (your PR) - 15717840 (main) = 28736 => ~28KiB.
It seems like |
a58a3e1
to
818d31b
Compare
Signed-off-by: Fabian Mettler <[email protected]> (cherry picked from commit 21ed02ae159abd398ea623406101f877d4092b59) Signed-off-by: Mark Bolton <[email protected]> License: Apache-2.0
Signed-off-by: Fabian Mettler <[email protected]> (cherry picked from commit 95bfa8881566ab6a66135a4709065d97feeaaa6b) Signed-off-by: Mark Bolton <[email protected]> License: Apache-2.0
Signed-off-by: Fabian Mettler <[email protected]> (cherry picked from commit b2dbe44d3447c554d9d7e5d4ee855238a7b27c6e) Signed-off-by: Mark Bolton <[email protected]> License: Apache-2.0
Signed-off-by: Fabian Mettler <[email protected]> (cherry picked from commit 8f0061f699db14ba101378ca4314c3ee33afd93c) Signed-off-by: Mark Bolton <[email protected]> License: Apache-2.0
Signed-off-by: Fabian Mettler <[email protected]> (cherry picked from commit f4b0e4dad87ebc1bd0cc94d9b6b0cdaa0a848020) Signed-off-by: Mark Bolton <[email protected]> License: Apache-2.0
Signed-off-by: Fabian Mettler <[email protected]> (cherry picked from commit db96183b5d2f728bcf92f65b54e9265a8ff7a5f5) Signed-off-by: Mark Bolton <[email protected]> License: Apache-2.0
Signed-off-by: Fabian Mettler <[email protected]> (cherry picked from commit 5f6dbb7bea79b315797533d792ff81c3a0bc8fbb) Signed-off-by: Mark Bolton <[email protected]> License: Apache-2.0
Signed-off-by: Fabian Mettler <[email protected]> (cherry picked from commit d5b4350adc2f318ed9fdfd1078eaf8e7f00e8f88) Signed-off-by: Mark Bolton <[email protected]> License: Apache-2.0
Signed-off-by: Mark Bolton <[email protected]>
Signed-off-by: Mark Bolton <[email protected]>
Signed-off-by: Mark Bolton <[email protected]>
Signed-off-by: Mark Bolton <[email protected]>
Signed-off-by: Fabian Mettler <[email protected]> (cherry picked from commit 679ce9355b1f16cbf2a825eb3f0b901b80f35298) Signed-off-by: Mark Bolton <[email protected]> License: Apache-2.0
Signed-off-by: Fabian Mettler <[email protected]> (cherry picked from commit 2e6756328f2e72b1d2b1704a2b2b4373230e2cee) Signed-off-by: Mark Bolton <[email protected]> License: Apache-2.0
Signed-off-by: Fabian Mettler <[email protected]> (cherry picked from commit 98693c062efc05ec500022e7032e63ca96c291ba) Signed-off-by: Mark Bolton <[email protected]> License: Apache-2.0
Signed-off-by: Mark Bolton <[email protected]>
Signed-off-by: Fabian Mettler <[email protected]> (cherry picked from commit 50f73d42057032403b29e5986763d265cfcb5256) Signed-off-by: Mark Bolton <[email protected]> License: Apache-2.0
Signed-off-by: Mark Bolton <[email protected]>
Signed-off-by: Mark Bolton <[email protected]>
818d31b
to
1bf4b1a
Compare
This PR adds support for storage bucket backups. It includes cherry-picks from lxc/incus#365, and the below description comes in part from the associated incus PR.
Description
API
The following endpoints are added, along with the
storage_bucket_backup
extension:Export
CLI
Archive
The export command creates a tarball from the defined bucket, which is structured as follows:
bucket
directory contains the actual databackup.yml
contains the bucket metadata and keys:Import
CLI
Design decisions of note
TransferManager
struct is implemented, which utilizes MinIO to handle downloading files from a bucket to create the backup, and uploading files to a bucket when creating a bucket from a backup.Overall, what's been changed