-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
br: Skip verify region if the provider is ceph or minio #42366
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -177,6 +177,7 @@ func (options *S3BackendOptions) Apply(s3 *backuppb.S3) error { | |||
} | ||||
|
||||
s3.Endpoint = strings.TrimSuffix(options.Endpoint, "/") | ||||
s3.Provider = options.Provider | ||||
s3.Region = options.Region | ||||
// StorageClass, SSE and ACL are acceptable to be empty | ||||
s3.StorageClass = options.StorageClass | ||||
|
@@ -358,38 +359,45 @@ func NewS3Storage(ctx context.Context, backend *backuppb.S3, opts *ExternalStora | |||
) | ||||
} | ||||
c := s3.New(ses, s3CliConfigs...) | ||||
confCred := ses.Config.Credentials | ||||
setCredOpt := func(req *request.Request) { | ||||
// s3manager.GetBucketRegionWithClient will set credential anonymous, which works with s3. | ||||
// we need reassign credential to be compatible with minio authentication. | ||||
if confCred != nil { | ||||
req.Config.Credentials = confCred | ||||
|
||||
// s3manager.GetBucketRegionWithClient failed to get region from client if the client is ceph or minio | ||||
// It defaults back to us-west-1 which breaks the code if a region is already set | ||||
if qs.Provider != "ceph" && qs.Provider != "minio" { | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
From the CI checks:
|
||||
confCred := ses.Config.Credentials | ||||
setCredOpt := func(req *request.Request) { | ||||
// s3manager.GetBucketRegionWithClient will set credential anonymous, which works with s3. | ||||
// we need reassign credential to be compatible with minio authentication. | ||||
if confCred != nil { | ||||
req.Config.Credentials = confCred | ||||
} | ||||
// s3manager.GetBucketRegionWithClient use path style addressing default. | ||||
// we need set S3ForcePathStyle by our config if we set endpoint. | ||||
if qs.Endpoint != "" { | ||||
req.Config.S3ForcePathStyle = ses.Config.S3ForcePathStyle | ||||
} | ||||
} | ||||
// s3manager.GetBucketRegionWithClient use path style addressing default. | ||||
// we need set S3ForcePathStyle by our config if we set endpoint. | ||||
if qs.Endpoint != "" { | ||||
req.Config.S3ForcePathStyle = ses.Config.S3ForcePathStyle | ||||
region, err := s3manager.GetBucketRegionWithClient(ctx, c, qs.Bucket, setCredOpt) | ||||
if err != nil { | ||||
return nil, errors.Annotatef(err, "failed to get region of bucket %s", qs.Bucket) | ||||
} | ||||
} | ||||
region, err := s3manager.GetBucketRegionWithClient(ctx, c, qs.Bucket, setCredOpt) | ||||
if err != nil { | ||||
return nil, errors.Annotatef(err, "failed to get region of bucket %s", qs.Bucket) | ||||
} | ||||
|
||||
if qs.Region != region { | ||||
if qs.Region != "" { | ||||
return nil, errors.Trace(fmt.Errorf("s3 bucket and region are not matched, bucket=%s, input region=%s, real region=%s", | ||||
qs.Bucket, qs.Region, region)) | ||||
} | ||||
if qs.Region != region { | ||||
if qs.Region != "" { | ||||
return nil, errors.Trace(fmt.Errorf("s3 bucket and region are not matched, bucket=%s, input region=%s, real region=%s", | ||||
qs.Bucket, qs.Region, region)) | ||||
} | ||||
|
||||
qs.Region = region | ||||
backend.Region = region | ||||
if region != defaultRegion { | ||||
s3CliConfigs = append(s3CliConfigs, aws.NewConfig().WithRegion(region)) | ||||
c = s3.New(ses, s3CliConfigs...) | ||||
qs.Region = region | ||||
backend.Region = region | ||||
if region != defaultRegion { | ||||
s3CliConfigs = append(s3CliConfigs, aws.NewConfig().WithRegion(region)) | ||||
c = s3.New(ses, s3CliConfigs...) | ||||
} | ||||
} | ||||
|
||||
log.Info("succeed to get bucket region from s3", zap.String("bucket region", region)) | ||||
} | ||||
log.Info("succeed to get bucket region from s3", zap.String("bucket region", region)) | ||||
|
||||
if len(qs.Prefix) > 0 && !strings.HasSuffix(qs.Prefix, "/") { | ||||
qs.Prefix += "/" | ||||
|
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.
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.
qs.Provider == "s3"
(or GCS?)ProviderConfig.check_bucket_with_region == true
and then elsewhere store the config for each provider.These are just ideas, I have no objections on merging this as-is.
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.
1 . I'm not sure about the list. We add ceph and minio because it's what we are working with and had troubles, but the issues may be wider.
2 Would it be simpler to add a parameter like qs.SkipBucketRegionCheck and a tag --skip-bucket-region-check when we launch br ? ( the wording is a bit long ^^")