sarama icon indicating copy to clipboard operation
sarama copied to clipboard

Implement resolve_canonical_bootstrap_servers_only

Open gebn opened this issue 4 years ago • 1 comments

This PR allows specifying the equivalent of client.dns.lookup=resolve_canonical_bootstrap_servers_only, described in KIP-235. The motivation is identical to the one in the proposal: the lack of this feature effectively mandates providing individual canonical broker hostnames when using GSSAPI, rather than a single alias which resolves to the same underlying IPs. This increases the likelihood of errors, and commits application owners to checking for new and removed brokers on an ongoing basis.

The Java client implementation for this can be found here.

The config could be designed as a type DNSLookupStrategy int8 enum, with UseAllDNSIPs and ResolveCanonicalBootstrapServersOnly values, however I went for the bool as there is no precedent for mirroring the Java API, and this seemed much simpler to understand.

I was torn about adding context.Context to resolveCanonicalNames()'s signature. To be consistent with existing code, I've kept this internal. It is not fully supported anyway due to Net.Proxy.Dialer being a proxy.Dialer rather than proxy.ContextDialer.

gebn avatar Feb 22 '22 04:02 gebn

@dnwe Please let me know if this is missing anything!

gebn avatar Feb 27 '23 17:02 gebn

@dnwe I've rebased and added Signed-off-by. Still really keen to add this feature :)

gebn avatar Jul 12 '23 22:07 gebn

The Test with Kafka 3.1.2 failure was due to a timeout only 8 tests from the end:

STATUS ELAPSED PACKAGE COVER PASS FAIL SKIP
FAIL 960.07s github.com/Shopify/sarama - 423 8 1
PASS 0.03s github.com/Shopify/sarama/examples/http_server 22.5% 3 0 0
PASS 0.04s github.com/Shopify/sarama/mocks 82.1% 36 0 0

There are no changes here that would affect performance once connected to brokers, so I think that's a false negative. I've rebased, can you re-approve the workflow to give it another go?

gebn avatar Jul 18 '23 01:07 gebn

Thanks! Please let me know if I need to do anything else - I'll hold off rebasing the source branch, as it'll only wait for the checks to be re-approved.

gebn avatar Jul 31 '23 12:07 gebn