Skip to content

Correctly aquire information on AWS_REGION - #49

Open
VitaliyDm wants to merge 3 commits into
wal-g:masterfrom
VitaliyDm:getAwsRegion
Open

Correctly aquire information on AWS_REGION#49
VitaliyDm wants to merge 3 commits into
wal-g:masterfrom
VitaliyDm:getAwsRegion

Conversation

@VitaliyDm

Copy link
Copy Markdown

@usernamedt

usernamedt commented Jun 7, 2021

Copy link
Copy Markdown
Member

Hi! Thank you for this fix! It looks like that your PR has conflicts with the master branch, please rebase

@VitaliyDm

Copy link
Copy Markdown
Author

Hi! Thank you for this fix! It looks like that your PR has conflicts with the master branch, please rebase

Hi! Fixed

Comment thread s3/session.go
return region, nil
}

if config.Endpoint == nil ||

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This new extracting logic deserves extracting into a separate function, just like the findBucketRegion

Comment thread s3/session.go

host, _, err := net.SplitHostPort(hostAddr.Host)

if err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In this logic, if WAL-G failed to parse the endpoint host, it won't attempt to call findBucketRegion, is it intended behavior?
I think that WAL-G should always try both approaches before giving up.

Comment thread s3/session_test.go
var config = defaults.Get().Config.WithRegion(settings[RegionSetting])

func TestGetAWSRegionWithEmptyEndpoint(t *testing.T) {
findBucketRegion = func(bucket string, config *aws.Config) (string, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe I missed the point, but I think that we just need to provide different aws.Config and compare the result with the expected one? Basically, write unit tests for these functions:

  1. findBucketRegion
  2. The new function which extracts the region from the hostname

@usernamedt

Copy link
Copy Markdown
Member

Hi!

This repository is going to be merged into the wal-g main repo. Please submit any future updates to the main repository.

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants