Browse Source

Merge pull request #3233 from xiang90/srv_discovery

better dns discovery error and doc
Xiang Li 10 years ago
parent
commit
7314310aed
2 changed files with 9 additions and 0 deletions
  1. 6 0
      Documentation/clustering.md
  2. 3 0
      etcdmain/etcd.go

+ 6 - 0
Documentation/clustering.md

@@ -300,6 +300,8 @@ infra2.example.com.	300	IN	A	10.0.1.12
 
 etcd cluster members can listen on domain names or IP address, the bootstrap process will resolve DNS A records.
 
+The resolved address in `-initial-advertise-peer-urls` *must match* one of the resolved addresses in the SRV targets. The etcd member reads the resolved address to find out if it belongs to the cluster defined in the SRV records.
+
 ```
 $ etcd -name infra0 \
 -discovery-srv example.com \
@@ -376,6 +378,10 @@ DNS SRV records can also be used to configure the list of peers for an etcd serv
 $ etcd --proxy on -discovery-srv example.com
 ```
 
+#### Error Cases
+
+You might see the an error like `cannot find local etcd $name from SRV records.`. That means the etcd member fails to find itself from the cluster defined in SRV records. The resolved address in `-initial-advertise-peer-urls` *must match* one of the resolved addresses in the SRV targets.
+
 # 0.4 to 2.0+ Migration Guide
 
 In etcd 2.0 we introduced the ability to listen on more than one address and to advertise multiple addresses. This makes using etcd easier when you have complex networking, such as private and public networks on various cloud providers.

+ 3 - 0
etcdmain/etcd.go

@@ -422,6 +422,9 @@ func getPeerURLsMapAndToken(cfg *config) (urlsmap types.URLsMap, token string, e
 			return nil, "", err
 		}
 		urlsmap, err = types.NewURLsMap(clusterStr)
+		if _, ok := urlsmap[cfg.name]; !ok {
+			return nil, "", fmt.Errorf("cannot find local etcd member %q in SRV records", cfg.name)
+		}
 	default:
 		// We're statically configured, and cluster has appropriately been set.
 		urlsmap, err = types.NewURLsMap(cfg.initialCluster)