Skip to content

Conversation

@VitaliyDm
Copy link

@usernamedt
Copy link
Member

usernamedt commented Jun 7, 2021

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

@VitaliyDm
Copy link
Author

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

Hi! Fixed

return region, nil
}

if config.Endpoint == nil ||
Copy link
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


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

if err != nil {
Copy link
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.

var config = defaults.Get().Config.WithRegion(settings[RegionSetting])

func TestGetAWSRegionWithEmptyEndpoint(t *testing.T) {
findBucketRegion = func(bucket string, config *aws.Config) (string, error) {
Copy link
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
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