-
Notifications
You must be signed in to change notification settings - Fork 935
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
IdleConnTimeout: 30 * time.Second, | ||
DisableCompression: true, | ||
TLSClientConfig: &tls.Config{ | ||
InsecureSkipVerify: true, |
Check failure
Code scanning / CodeQL
Disabled TLS certificate check High
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.
I agree with CodeQL that it's risky. It should ideally be done only if requested by the user.
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.
@boltmark Could you please make that InsecureSkipVerify
configurable and defaulting to false
? Thanks!
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
22b47a3
to
3c5bc1b
Compare
3c5bc1b
to
110a180
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: 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: Mark Bolton <[email protected]>
110a180
to
0b223d7
Compare
backend="${2}" | ||
accessKey="${3}" | ||
secretKey="${4}" | ||
shift 3 |
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.
shift 3 | |
shift 4 |
IdleConnTimeout: 30 * time.Second, | ||
DisableCompression: true, | ||
TLSClientConfig: &tls.Config{ | ||
InsecureSkipVerify: 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.
@boltmark Could you please make that InsecureSkipVerify
configurable and defaulting to false
? Thanks!
return err | ||
} | ||
|
||
bucketURL := b.GetBucketURL(bucket.Name) |
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.
Hrm, ive not reviewed this yet in detail, but @simondeziel comment about InsecureSkipVerify caught me eye, but not because of the security implications (clearly they are undesirable) but more that it indicates that we have the LXD process apparently (in the case of minio based buckets) looping back to itself (@boltmark this anti-pattern will be familiar to you from your project force deletion PR too) in order to download all the files in an s3 bucket.
Now, I'm guessing the reason its been done like this is in order to support Ceph RADOS buckets (https://documentation.ubuntu.com/lxd/en/latest/reference/storage_cephobject/) where the b.GetBucketURL
will be an external service (not LXD).
However this then got me thinking, why haven't we come across this issue before, and the answer appears to be, we have, and it was solved by:
lxd/lxd/storage/drivers/driver_cephobject_buckets.go
Lines 30 to 75 in b784423
// s3Client returns a configured minio S3 client. | |
func (d *cephobject) s3Client(creds S3Credentials) (*minio.Client, error) { | |
u, err := url.ParseRequestURI(d.config["cephobject.radosgw.endpoint"]) | |
if err != nil { | |
return nil, fmt.Errorf("Failed parsing cephobject.radosgw.endpoint: %w", err) | |
} | |
var transport http.RoundTripper | |
certFilePath := d.config["cephobject.radosgw.endpoint_cert_file"] | |
if u.Scheme == "https" && certFilePath != "" { | |
certFilePath = shared.HostPath(certFilePath) | |
// Read in the cert file. | |
certs, err := os.ReadFile(certFilePath) | |
if err != nil { | |
return nil, fmt.Errorf("Failed reading %q: %w", certFilePath, err) | |
} | |
rootCAs := x509.NewCertPool() | |
ok := rootCAs.AppendCertsFromPEM(certs) | |
if !ok { | |
return nil, fmt.Errorf("Failed adding S3 client certificates") | |
} | |
// Trust the cert pool in our client. | |
config := &tls.Config{ | |
RootCAs: rootCAs, | |
} | |
transport = &http.Transport{TLSClientConfig: config} | |
} | |
minioClient, err := minio.New(path.Join(u.Host, u.Path), &minio.Options{ | |
Creds: credentials.NewStaticV4(creds.AccessKey, creds.SecretKey, ""), | |
Secure: u.Scheme == "https", | |
Transport: transport, | |
}) | |
if err != nil { | |
return nil, err | |
} | |
return minioClient, nil | |
} |
and for minio backends (which uses http rather than https as LXD's minio is only bound to local-loopback):
lxd/lxd/storage/s3/miniod/miniod.go
Lines 75 to 85 in b784423
func (p *Process) S3Client() (*minio.Client, error) { | |
s3Client, err := minio.New(p.url.Host, &minio.Options{ | |
Creds: credentials.NewStaticV4(p.username, p.password, ""), | |
Secure: false, | |
}) | |
if err != nil { | |
return nil, err | |
} | |
return s3Client, nil | |
} |
So we need to check if using these existing client functions allow LXD to connect directly to the s3 service (rather than looping through LXD in the case of minio) and avoid the skipping of TLS checks when connecting to an external ceph rados gw service when TLS is enabled?
Also, suggest looking for follow up commits in Incus to see if this has already been addressed.
Also, if simpler, we could add to the storage drivers interface a GetS3Client()
function which each storage driver could supply, to make the logic simpler in backendLXD.
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.
Need to resolve the loop-back and TLS checks skipping issue.
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