Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

【DNM】* *: support meta with s3#66

Closed
DanielZhangQD wants to merge 3 commits intopingcap:masterfrom
DanielZhangQD:metas3
Closed

【DNM】* *: support meta with s3#66
DanielZhangQD wants to merge 3 commits intopingcap:masterfrom
DanielZhangQD:metas3

Conversation

@DanielZhangQD
Copy link
Contributor

@DanielZhangQD DanielZhangQD commented Nov 25, 2019

Support storing backup meta with S3.

Here are the commands to use:

  • backup
    • ./br backup full --pd 10.233.0.168:2379 --storage "s3://danz-backup6/backup11251525?access_key=aaa&secret_access_key=bbb&region=us-west-2&provider=aws&prefix=backup11251525"
  • checksum
    • ./br meta checksum --storage "s3://danz-backup6/backup11251525?access_key=aaa&secret_access_key=bbb&region=us-west-2&provider=aws&prefix=backup11251525"
  • restore
    • ./br restore full --pd 10.233.9.21:2379 --storage "s3://danz-backup6/backup11251525?access_key=aaa&secret_access_key=bbb&region=us-west-2&provider=aws&prefix=backup11251525"

@codecov
Copy link

codecov bot commented Nov 25, 2019

Codecov Report

Merging #66 into master will decrease coverage by 3%.
The diff coverage is 4.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #66      +/-   ##
==========================================
- Coverage    62.2%   59.19%   -3.01%     
==========================================
  Files          22       23       +1     
  Lines        2643     2779     +136     
==========================================
+ Hits         1644     1645       +1     
- Misses        768      901     +133     
- Partials      231      233       +2
Impacted Files Coverage Δ
pkg/utils/remote_storage.go 0% <0%> (ø)
pkg/backup/client.go 50.7% <20%> (-0.13%) ⬇️
pkg/utils/storage.go 65.21% <45.45%> (-6.22%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76a40df...372503a. Read the comment docs.

@tennix tennix self-assigned this Nov 26, 2019
@DanielZhangQD DanielZhangQD changed the title * *: support meta with s3 [WIP] * *: support meta with s3 Nov 26, 2019
@DanielZhangQD DanielZhangQD changed the title [WIP] * *: support meta with s3 * *: support meta with s3 Nov 26, 2019
@DanielZhangQD
Copy link
Contributor Author

@overvenus @tennix @onlymellb PTAL the new commit with aws-sdk-go.

@DanielZhangQD
Copy link
Contributor Author

@overvenus @kennytm @tennix @onlymellb PTAL the new commit with go cloud dev kit, thanks!

Copy link
Collaborator

@kennytm kennytm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add a test case? Use a S3 mock or minio or whatever...

if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case s3.ErrCodeNoSuchBucket, notFound:
return createS3Bucket(svc, bucket)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it is desired to create a bucket by default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better that users create the bucket by themselves and br just uses it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but here BR creates a bucket if it's missing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can try to create the bucket if it's missing, but we'd add a document to tell users to create themselves. The minimal permission required is to read and write objects in the specified bucket.

This can avoid starting over again if users forgot to create the bucket.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will make it clear in the document that:

  1. Suggest users creating the bucket by themselves.
  2. If not, BR will create it automatically with the default configuration, and users have to handle the ACLs and any other attributes they want to set by themselves.

Comment on lines +208 to +211
prs, ok := qs[providerKey]
if ok && len(prs) >= 1 {
sqs.provider = prs[0]
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps use the URL scheme oss://bucket for Aliyun OSS and s3://bucket for AWS S3 instead? Automatically set the endpoint to oss-$region.aliyuncs.com if the URL scheme is oss://.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sharing this info, I'd like to test Aliyun and change the necessary code in another issue, currently, focus on AWS S3 and Ceph.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#70

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I expect would be

  • Remove provider
  • One of region or endpoint must be supplied

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the internal protocol, I think using the unified URL as gocloud does should be OK. For user interface, I agree we can make it less verbose by adopting oss/s3/ceph/minio etc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how provider can simplify config for Ceph or Minio.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update this if necessary when the interface between BR and TiKV is determined.

@DanielZhangQD
Copy link
Contributor Author

@kennytm comments addressed, PTAL again, thanks!

sqs.bucket = u.Host

if u.Path != "" {
log.Info("path in storage arg is ignored", zap.String("path", u.Path))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log.Info("path in storage arg is ignored", zap.String("path", u.Path))
log.Warn("path in storage arg is ignored", zap.String("path", u.Path))

Let's make this a warning

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case s3.ErrCodeNoSuchBucket, notFound:
return createS3Bucket(svc, bucket)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but here BR creates a bucket if it's missing

Comment on lines +208 to +211
prs, ok := qs[providerKey]
if ok && len(prs) >= 1 {
sqs.provider = prs[0]
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I expect would be

  • Remove provider
  • One of region or endpoint must be supplied

@IANTHEREAL IANTHEREAL changed the title * *: support meta with s3 【DMN】* *: support meta with s3 Dec 1, 2019
@tennix tennix changed the title 【DMN】* *: support meta with s3 【DNM】* *: support meta with s3 Dec 8, 2019
@DanielZhangQD
Copy link
Contributor Author

#88 has updated the storage interface and reorganized the code structure, close this PR and will submit another one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants