Ver código fonte

Merge pull request #2951 from yichengq/fix-proxy-acurls

etcdmain: fix that advertise-client-urls is required in proxy mode
Yicheng Qin 10 anos atrás
pai
commit
ed1c5a73d1
2 arquivos alterados com 7 adições e 3 exclusões
  1. 1 1
      Procfile
  2. 6 2
      etcdmain/config.go

+ 1 - 1
Procfile

@@ -2,4 +2,4 @@
 etcd1: bin/etcd -name infra1 -listen-client-urls http://localhost:4001 -advertise-client-urls http://localhost:4001 -listen-peer-urls http://localhost:7001 -initial-advertise-peer-urls http://localhost:7001 -initial-cluster-token etcd-cluster-1 -initial-cluster 'infra1=http://localhost:7001,infra2=http://localhost:7002,infra3=http://localhost:7003' -initial-cluster-state new
 etcd2: bin/etcd -name infra2 -listen-client-urls http://localhost:4002 -advertise-client-urls http://localhost:4002 -listen-peer-urls http://localhost:7002 -initial-advertise-peer-urls http://localhost:7002 -initial-cluster-token etcd-cluster-1 -initial-cluster 'infra1=http://localhost:7001,infra2=http://localhost:7002,infra3=http://localhost:7003' -initial-cluster-state new
 etcd3: bin/etcd -name infra3 -listen-client-urls http://localhost:4003 -advertise-client-urls http://localhost:4003 -listen-peer-urls http://localhost:7003 -initial-advertise-peer-urls http://localhost:7003 -initial-cluster-token etcd-cluster-1 -initial-cluster 'infra1=http://localhost:7001,infra2=http://localhost:7002,infra3=http://localhost:7003' -initial-cluster-state new
-proxy: bin/etcd -name proxy1 -proxy=on -bind-addr 127.0.0.1:8080 -initial-cluster 'infra1=http://localhost:7001,infra2=http://localhost:7002,infra3=http://localhost:7003'
+proxy: bin/etcd -name proxy1 -proxy=on -listen-client-urls http://localhost:8080 -initial-cluster 'infra1=http://localhost:7001,infra2=http://localhost:7002,infra3=http://localhost:7003'

+ 6 - 2
etcdmain/config.go

@@ -269,8 +269,12 @@ func (cfg *config) Parse(arguments []string) error {
 	if err != nil {
 		return err
 	}
-	if flags.IsSet(cfg.FlagSet, "listen-client-urls") && !flags.IsSet(cfg.FlagSet, "advertise-client-urls") {
-		return errUnsetAdvertiseClientURLsFlag
+
+	// when etcd runs in member mode user needs to set -advertise-client-urls if -listen-client-urls is set.
+	if cfg.proxy.String() != proxyFlagOn {
+		if flags.IsSet(cfg.FlagSet, "listen-client-urls") && !flags.IsSet(cfg.FlagSet, "advertise-client-urls") {
+			return errUnsetAdvertiseClientURLsFlag
+		}
 	}
 
 	if 5*cfg.TickMs > cfg.ElectionMs {