Explorar o código

etcd-tester: fix peer-port parsing bug with localhost url

The following format "http://localhost:1234" causes existing port parser to fail. Add new logic to parse the host name first then extract port.

Fixes #6409
fanmin shi %!s(int64=9) %!d(string=hai) anos
pai
achega
8a63071463
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      tools/functional-tester/etcd-tester/member.go

+ 5 - 1
tools/functional-tester/etcd-tester/member.go

@@ -168,7 +168,11 @@ func (m *member) grpcAddr() string {
 }
 
 func (m *member) peerPort() (port int) {
-	_, portStr, err := net.SplitHostPort(m.PeerURL)
+	u, err := url.Parse(m.PeerURL)
+	if err != nil {
+		panic(err)
+	}
+	_, portStr, err := net.SplitHostPort(u.Host)
 	if err != nil {
 		panic(err)
 	}