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

Change graphite connect logic to lookup dns names on reconnect #1493

Merged
merged 1 commit into from
Oct 19, 2019

Conversation

goraxe
Copy link
Contributor

@goraxe goraxe commented Oct 17, 2019

We had various issues with dns names for our graphite host changing (its an aws ALB and the ip addresses rotate fairly frequently). I have tracked down the issue to the hostname not being re-resolved by InetSockAddress once it has an address. This code will now always attempt to re-resolve (with default java jvm ttl of 30s, or dns resolve cache ttl applying)

@arteam
Copy link
Member

arteam commented Oct 19, 2019

I think this change actually better, because it explicitly forces a DNS lookup every time GraphiteReporter reports metric. I will cut a new release with this change.

@arteam arteam merged commit c845825 into dropwizard:4.1-development Oct 19, 2019
@arteam
Copy link
Member

arteam commented Oct 19, 2019

Thank you, @goraxe! I've released Metrics 4.1.1 and 4.0.7 which should contain the change.

@arteam arteam added the bug label Oct 19, 2019
@arteam arteam added this to the 4.1.1 milestone Oct 19, 2019
@chengchen
Copy link

chengchen commented Nov 7, 2019

Hello @goraxe @arteam, I took a look at this commit and tried to use this constructor Graphite(InetSocketAddress address) to initialize Graphite. It seems that this fix is still not going to solve the issue, right?

Since the hostname would be null all the time, the address is always the old InetSocketAddress (not null), so address = new InetSocketAddress(InetAddress.getByName(hostname), port) will never be executed again.

@goraxe
Copy link
Contributor Author

goraxe commented Nov 18, 2019

@chengchen yes, we actually hit the same issue and switched to using the constructor Graphite(String hostname, String port). With the InetSocketAddress path there is not an easy way to get at the original hostname (reverse dns may not point at the dns name for eg). I didn't want to mess with the api to deprecate the InetSocketAddress constructor as that might be valid uses cases for it (I'm just a drive by contributor so its not my call to make) there is the caveat that dns changes will not propagate (as that has been explictly done outside of the graphite code).

@chengchen
Copy link

@goraxe Thanks for the explanations. I noticed this inconsistency because we were using InetSocketAddress.createUnresolved(String host, int port) to work around this problem in the past. And your changes made it broken completely. Now, I look back into this code realizing that using Graphite(String hostname, String port) works just fine even without your changes. That's basically why I was asking. IMHO, this class requires some serious cleanup but of course, this is not a message for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants