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

Enable discovery of cluster nodes through DNS SRV #1337

Closed
wants to merge 4 commits into from

Conversation

kocolosk
Copy link
Member

Overview

This patch enables CouchDB nodes to check SRV records in DNS for cluster peers and automatically add any discovered peers to the nodes DB. This behavior is disabled by default and can be enabled as follows:

[mem3]
use_dns_service_discovery = true
service_record_name = _couchdb._tcp.example.net

If the service_record_name is omitted we attempt to generate the appropriate record for the query by prepending _couchdb._tcp. to the DNS domain name portion of the host / VM / container FQDN.

I wrote this code a few months back and it passed some smoke tests in Kube but I never opened a PR. Opening it now so I don't forget about it.

Testing recommendations

  1. Start one CouchDB node
  2. Create an SRV record pointing to it
  3. Start a second node with the [mem3] configuration above
  4. Check to see if they automatically join into a cluster

Related Issues or Pull Requests

Fixes #1108

Checklist

  • Code is written and works correctly;
  • Changes are covered by tests;
  • Documentation reflects the changes;

kocolosk and others added 3 commits January 13, 2018 21:34
This patch enables CouchDB nodes to check SRV records in DNS for cluster
peers and automatically add any discovered peers to the nodes DB. This
behavior is disabled by default and can be enabled as follows:

[mem3]
use_dns_service_discovery = true
service_record_name = _couchdb._tcp.example.net

If the `service_record_name` is omitted we attempt to generate the
appropriate record for the query by prepending _couchdb._tcp. to the DNS
domain name portion of the host / VM / container FQDN.
Copy link
Member

@janl janl left a comment

Choose a reason for hiding this comment

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

+1 after rebase

construct_service_record() ->
case config:get("mem3", "service_record_name") of
undefined ->
[_ | Domain] = string:tokens(net_adm:localhost(), "."),
Copy link
Member

Choose a reason for hiding this comment

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

Tested this on Windows and it fails:

Eshell V8.3  (abort with ^G)
1> [_ | Domain] = string:tokens(net_adm:localhost(), ".").
["DESKTOP-1AA2L3B"]
2> {ok, string:join(["_couchdb", "_tcp" | Domain], ".")}.
{ok,"_couchdb._tcp"}

I know this isn't your ideal deployment scenario, but someone's going to try it...and we need to have a fallback when it fails to get a proper domain name.

Copy link
Member

Choose a reason for hiding this comment

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

I get that you can just override it with mem3:service_record_name, but in case you don't, we should fail semi-gracefully.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, thanks.

Copy link
Member

@wohali wohali left a comment

Choose a reason for hiding this comment

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

Needs fixing on Windows.

@wohali
Copy link
Member

wohali commented Jan 8, 2020

@kocolosk are we abandoning this work in favour of the current -helm approach?

@kocolosk
Copy link
Member Author

kocolosk commented Jan 8, 2020

If someone wanted to bring it over the finish line I'd be happy to review and merge, but it's a low priority for me given the seedlist capability now adopted by the Helm chart. We can close this PR to clean things up.

@kocolosk kocolosk closed this Jan 8, 2020
@wohali wohali deleted the dns-cluster-discovery branch October 21, 2020 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query DNS to automatically discover cluster peers
3 participants