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

Etcd DNS discovery #2521

Merged
merged 2 commits into from
Apr 4, 2017
Merged

Etcd DNS discovery #2521

merged 2 commits into from
Apr 4, 2017

Conversation

jsok
Copy link
Contributor

@jsok jsok commented Mar 22, 2017

Adds a new etcd config option discovery_srv which contains the domain name which the etcd client will use to perform DNS SRV record discovery.

Fixes #2519

@jsok jsok force-pushed the 2519-etcd-discovery-srv branch 5 times, most recently from 6c004c3 to 55f0e36 Compare March 22, 2017 09:43
@jefferai
Copy link
Member

Pinging @xiang90

@xiang90
Copy link
Contributor

xiang90 commented Mar 28, 2017

I will take a look over the weekend or early next week.

physical/etcd.go Outdated
@@ -13,6 +16,7 @@ import (
var (
EtcdSyncConfigError = errors.New("client setup failed: unable to parse etcd sync field in config")
EtcdSyncClusterError = errors.New("client setup failed: unable to sync etcd cluster")
EtcdMultipleDiscoveryError = errors.New("client setup failed: multiple discovery or bootstrap flags specified, use either \"address\" or \"discovery_srv\"")
Copy link
Contributor

Choose a reason for hiding this comment

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

MultipleBootstrapError?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do

physical/etcd.go Outdated
@@ -95,3 +99,44 @@ func getEtcdAPIVersion(c client.Client) (string, error) {

return "3", nil
}

func getEtcdEndpoints(conf map[string]string) ([]string, error) {
getOption := func(conf_key, env_var string) (string, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why this func is embedded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it looks generally useful I can move it up to the module scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted.

physical/etcd.go Outdated

func getEtcdEndpoints(conf map[string]string) ([]string, error) {
getOption := func(conf_key, env_var string) (string, bool) {
conf_val, in_conf := conf[conf_key]
Copy link
Contributor

Choose a reason for hiding this comment

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

confVal instead of conf_val. use camelcase instead of underscore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

physical/etcd.go Outdated
discoverer := client.NewSRVDiscover()
endpoints, err := discoverer.Discover(domain)
if err != nil {
return nil, fmt.Errorf("etcd SRV discovery: %s", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

failed to discovery etcd endpoints through SRV discovery: %v

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -122,3 +138,4 @@ storage "etcd" {
```

[etcd]: https://coreos.com/etcd "Etcd by CoreOS"
[dns discovery]: https://coreos.com/etcd/docs/latest/v2/clustering.html#dns-discovery "Etcd cluster DNS Discovery"
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@xiang90
Copy link
Contributor

xiang90 commented Apr 3, 2017

@jsok Have you gave this a try? I want to make sure it works.

@xiang90
Copy link
Contributor

xiang90 commented Apr 3, 2017

looks good in general.

@jsok
Copy link
Contributor Author

jsok commented Apr 3, 2017

@xiang90 yes I've tested local with a 3-node etcd cluster with SSL.

@xiang90
Copy link
Contributor

xiang90 commented Apr 4, 2017

lgtm

@jefferai
Copy link
Member

jefferai commented Apr 4, 2017

Merging with the 👍 from @xiang90

@jefferai jefferai merged commit e5013e9 into hashicorp:master Apr 4, 2017
@jefferai jefferai added this to the 0.7.1 milestone Apr 4, 2017
@jsok jsok deleted the 2519-etcd-discovery-srv branch December 17, 2018 10:50
This pull request was closed.
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.

3 participants