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

fixes auto_join for mDNS provider #25080

Merged
merged 8 commits into from
Jun 10, 2024
Merged

fixes auto_join for mDNS provider #25080

merged 8 commits into from
Jun 10, 2024

Conversation

aubrich
Copy link
Contributor

@aubrich aubrich commented Jan 25, 2024

Fix issue with go-discover mDNS provider and auto-join (#25066)

@hashicorp-cla
Copy link

hashicorp-cla commented Jan 25, 2024

CLA assistant check
All committers have signed the CLA.

@aubrich aubrich closed this Jan 25, 2024
@aubrich aubrich reopened this Jan 25, 2024
@biazmoreira biazmoreira added bug Used to indicate a potential bug core/ha specific to high-availability labels Feb 19, 2024
@socheatsok78
Copy link
Contributor

socheatsok78 commented May 17, 2024

Hi @biazmoreira, I've recently encountered this problem when i try to use the mdns as the auto discovery mechanism as well, it seems that this PR would resolve this issue.

I was hoping that this will get merged at a reasonable time.

vault/raft.go Outdated
Comment on lines 1238 to 1246
} else if count > 0 && !strings.HasSuffix(ip, "]") {
tmpIp, portStr, err := net.SplitHostPort(ip)
if err == nil {
ip = tmpIp
tmpPort, err := strconv.Atoi(portStr)
if err == nil {
port = uint(tmpPort)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@aubrich would you be able to add unit testing for this? it might be interesting to isolate this in a function and unit test the function. this would give us more confidence we're not introducing bugs to the codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As you suggested I wrote a dedicated function and associated unit tests. I did not write test cases where disco.Addrs gives us something which is not an address.

Copy link
Contributor

@VioletHynes VioletHynes left a comment

Choose a reason for hiding this comment

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

Hi there! This looks good to me, and I'd love to approve it. I've left a few comments, and we'd also need a changelog describing concisely what's being fixed. There's some examples in the changelog directory but it'd be a file called 25080.txt that follows the same format as the other files in that directory (there should be a lot of inspiration, but if you want a hand let me know!)

I'm sorry this lingered so long, but if you're still interested in getting this in I'd love to help. I'm out of office tomorrow but will be back afterwards, and I'd love to help you get this over the line.

vault/raft.go Outdated
@@ -1459,3 +1458,19 @@ func newDiscover() (*discover.Discover, error) {
discover.WithProviders(providers),
)
}

// formatAddr join ip and port if addr does not already contain a port
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// formatAddr join ip and port if addr does not already contain a port
// formatDiscoveredAddr joins ip and port if addr does not already contain a port

"testing"
)

func TestFormatDiscoveredAddr(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be great if we could get a godoc for this function! Something starting with // TestFormatDiscoveredAddr and with a brief description of what it does

port uint
res string
}
cases := []TestCase{
Copy link
Contributor

Choose a reason for hiding this comment

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

This is mostly a question out of curiosity as opposed to something you should change, but out of interest: which of these would have failed with the old implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All cases where the port is returned with the address failed before. For example with this case 192.168.137.1:8201 vault would try to connect to 192.168.137.1:8201:8200

@aubrich
Copy link
Contributor Author

aubrich commented Jun 10, 2024

@VioletHynes sorry for the delay I was sick. Here are the modifications you requested. I hope the godoc and changelog are good enough, English is not my native language.

Copy link
Contributor

@VioletHynes VioletHynes left a comment

Choose a reason for hiding this comment

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

Hey there! Thanks for this, and thanks for adding my requested changes. I'm going to run CI, but assuming everything looks good, I'll try and merge this in.

Thank you for your patience in getting this reviewed :)

@VioletHynes VioletHynes merged commit d64856c into hashicorp:main Jun 10, 2024
66 of 67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to indicate a potential bug core/ha specific to high-availability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants