[GODRIVER-1174] Topology will prefer a non-resolvable hostname over one known to resolve Created: 29/Jun/19 Updated: 27/Oct/23 Resolved: 29/Jul/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | Server Discovery and Monitoring |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | John Morales | Assignee: | Isabella Siu (Inactive) |
| Resolution: | Gone away | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
mongo-driver @ 60e65d0f2639c81f74a92904fcd10900e37b9be6 (tip of repo as of June 28) |
||
| Issue Links: |
|
||||
| Description |
|
I'm not entirely positive this is an expected behavior, however I do have reproducer programs in Java and Go where the Java program is successful but equivalent golang program is not. Starting State (this can be setup locally on just a macbook, but I think is easier to illustrate in an environment with 2 servers):
Expected: client communication is fine, because we found the server on Host A using the seed list entry "hostname.acme.com:27017" which is valid. Java Program (successfully prints ping command response):
go-driver program and output:
Go program output:
Additional note: if the connection URI is instead: |
| Comments |
| Comment by David Golden [ 03/Jul/19 ] | |||||||||||||||||||||||||||
|
john.morales, in any split-horizon case (for any number of nodes), you'll need to use connect=direct to the public IP of one of the nodes. In 4.2, when split horizon support is released (PM-1289), you'll be able to do replica set connections to the public side of the split horizon (only if using TLS). avbee, currently, a replica set must be configured to use the same IP addresses for member communications and client communications. If your client is inside the containerized environment, then the replica set configuration can use internal IPs. If your client is outside the containerized environment, then the replica set members must be configured with the same externally-visible IP addresses used by the clients. For more on MongoDB with Kubernetes, please see this article and if you have additional questions, I encourage you to post on the mongodb-user group or Stack Overflow with the mongodb tag, as this ticket isn't the right place for general Kubernetes+MongoDB questions. | |||||||||||||||||||||||||||
| Comment by bimo adi [ 03/Jul/19 ] | |||||||||||||||||||||||||||
|
Hi @David Golden I have similar issue with connection using go driver to my mongo HA in k8s cluster, so i nly have 1 Public IP to access. When i tried to curl, it returns .
What is the correct way to connect? Snippet:
and it returns
| |||||||||||||||||||||||||||
| Comment by David Golden [ 02/Jul/19 ] | |||||||||||||||||||||||||||
|
I think the Java driver example is doing the equivalent of "connect=direct" because you have a single host and no replica set name. If you add the replica set name to the URI, I suspect you'll get the same result as the Go driver. (Drivers are not consistent about how they interpret URIs for direct vs replica set mode. See SPEC-1248.) SDAM says that in replica set mode, one should remove from the list of hosts anything that isn't in the member lists of the ismaster response, so the resolvable acme.com goes away and is replaced with the unresolvable .local. (I.e. this is the "split horizon" problem.) In direct connection mode, the server is treated as a standalone and the driver doesn't process the member lists of the ismaster response (and thus relies on the hostname provided in the seedlist). |