Merge pull request #3421 from xiang90/3411
etcdmain: proxy does not need to belong to the discovered clusterrelease-2.2
commit
53b8175d3f
|
@ -171,7 +171,7 @@ func Main() {
|
||||||
|
|
||||||
// startEtcd launches the etcd server and HTTP handlers for client/server communication.
|
// startEtcd launches the etcd server and HTTP handlers for client/server communication.
|
||||||
func startEtcd(cfg *config) (<-chan struct{}, error) {
|
func startEtcd(cfg *config) (<-chan struct{}, error) {
|
||||||
urlsmap, token, err := getPeerURLsMapAndToken(cfg)
|
urlsmap, token, err := getPeerURLsMapAndToken(cfg, "etcd")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error setting up initial cluster: %v", err)
|
return nil, fmt.Errorf("error setting up initial cluster: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ func startEtcd(cfg *config) (<-chan struct{}, error) {
|
||||||
|
|
||||||
// startProxy launches an HTTP proxy for client communication which proxies to other etcd nodes.
|
// startProxy launches an HTTP proxy for client communication which proxies to other etcd nodes.
|
||||||
func startProxy(cfg *config) error {
|
func startProxy(cfg *config) error {
|
||||||
urlsmap, _, err := getPeerURLsMapAndToken(cfg)
|
urlsmap, _, err := getPeerURLsMapAndToken(cfg, "proxy")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error setting up initial cluster: %v", err)
|
return fmt.Errorf("error setting up initial cluster: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -430,7 +430,7 @@ func startProxy(cfg *config) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPeerURLsMapAndToken sets up an initial peer URLsMap and cluster token for bootstrap or discovery.
|
// getPeerURLsMapAndToken sets up an initial peer URLsMap and cluster token for bootstrap or discovery.
|
||||||
func getPeerURLsMapAndToken(cfg *config) (urlsmap types.URLsMap, token string, err error) {
|
func getPeerURLsMapAndToken(cfg *config, which string) (urlsmap types.URLsMap, token string, err error) {
|
||||||
switch {
|
switch {
|
||||||
case cfg.durl != "":
|
case cfg.durl != "":
|
||||||
urlsmap = types.URLsMap{}
|
urlsmap = types.URLsMap{}
|
||||||
|
@ -445,8 +445,12 @@ func getPeerURLsMapAndToken(cfg *config) (urlsmap types.URLsMap, token string, e
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
urlsmap, err = types.NewURLsMap(clusterStr)
|
urlsmap, err = types.NewURLsMap(clusterStr)
|
||||||
if _, ok := urlsmap[cfg.name]; !ok {
|
// only etcd member must belong to the discovered cluster.
|
||||||
return nil, "", fmt.Errorf("cannot find local etcd member %q in SRV records", cfg.name)
|
// proxy does not need to belong to the discovered cluster.
|
||||||
|
if which == "etcd" {
|
||||||
|
if _, ok := urlsmap[cfg.name]; !ok {
|
||||||
|
return nil, "", fmt.Errorf("cannot find local etcd member %q in SRV records", cfg.name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// We're statically configured, and cluster has appropriately been set.
|
// We're statically configured, and cluster has appropriately been set.
|
||||||
|
|
Loading…
Reference in New Issue