Skip to content
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

Correctly aquire information on AWS_REGION #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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

if region, ok := settings[RegionSetting]; ok {
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
2 participants