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

storage: support GCS backup and restore#102

Merged
overvenus merged 15 commits intopingcap:masterfrom
SunRunAway:br-gcs
Dec 13, 2019
Merged

storage: support GCS backup and restore#102
overvenus merged 15 commits intopingcap:masterfrom
SunRunAway:br-gcs

Conversation

@SunRunAway
Copy link
Contributor

part of #89

GCS Support

store BR metadata to GCS


func newGCSStorage(gcs *backup.GCS) (*gcsStorage, error) {
var clientOps []option.ClientOption
clientOps = append(clientOps, option.WithCredentialsJSON([]byte(gcs.GetCredentialsBlob())))
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we are being forced into one particular way of doing credentials here. I am actually not sure what this is doing. But on GCE or GKE with the workload identity feature enabled the SDK will already automatically find credentials in the metadata.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since br is not sure that all the TiKV instances are deployed on GCE or GKE either, the simplest way is getting a credentials JSON and sending it to other TiKV instances.

Yes, I think it's a cool thing to use service account from environment on GCE or GKE. Maybe in the future and we have a idea to handle the credentials for TiKV instances.

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've created an issue #106

Copy link
Contributor

Choose a reason for hiding this comment

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

It happens automatically if you don't force one particular method like this. So you don't have to do anything to support it (other than not hard-code a particular auth technique).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If BR is not deployed on google cloud but on someone's IDC, we need this credentials file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, so I think all you need here is an if statement, something like:

creds := []byte(gcs.GetCredentialsBlob()
if creds != "" {
     	clientOps = append(clientOps, option.WithCredentialsJSON(creds))
}

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'll handle this on #106 because we need to deal with --send-credentials-to-tikv option here.

@codecov
Copy link

codecov bot commented Dec 12, 2019

Codecov Report

Merging #102 into master will decrease coverage by 0.37%.
The diff coverage is 65.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #102      +/-   ##
==========================================
- Coverage   70.34%   69.97%   -0.38%     
==========================================
  Files          30       31       +1     
  Lines        2799     2911     +112     
==========================================
+ Hits         1969     2037      +68     
- Misses        550      582      +32     
- Partials      280      292      +12
Impacted Files Coverage Δ
pkg/storage/s3.go 70% <ø> (ø) ⬆️
pkg/storage/noop.go 0% <0%> (ø) ⬆️
cmd/restore.go 57.04% <100%> (ø) ⬆️
cmd/validate.go 72.51% <100%> (+0.65%) ⬆️
cmd/backup.go 58.58% <100%> (ø) ⬆️
pkg/storage/flags.go 52.94% <33.33%> (-4.21%) ⬇️
pkg/storage/storage.go 40% <33.33%> (-10%) ⬇️
pkg/backup/client.go 71.07% <57.14%> (-0.1%) ⬇️
pkg/storage/gcs.go 60.91% <60.91%> (ø)
pkg/storage/local.go 80% <75%> (-10.48%) ⬇️
... and 3 more

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 464c157...2460ff3. Read the comment docs.

Copy link
Member

@tennix tennix left a comment

Choose a reason for hiding this comment

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

LGTM

@overvenus
Copy link
Member

Please fix the confliction for merging.

@SunRunAway
Copy link
Contributor Author

Please fix the confliction for merging.

rebased.

Comment on lines +50 to +52
"Specify the GCS storage class for objects. "+
"If it is not set, objects uploaded are followed by the default storage class of the bucket. "+
"See https://cloud.google.com/storage/docs/storage-classes for valid values.")
Copy link
Member

Choose a reason for hiding this comment

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

It would be better if you can wrap them within 80 chars.

@overvenus overvenus merged commit 1d11c5c into pingcap:master Dec 13, 2019
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