From 0d48fc5511fa3762e30f19e54e08d8a7b93085f9 Mon Sep 17 00:00:00 2001 From: Boris Dudelsack Date: Wed, 8 Mar 2017 19:00:11 +0100 Subject: [PATCH] gateway: fix the dns discovery method strip the scheme from the endpoints to have a clean hostname for TCP proxy Fixes #7452 --- etcdmain/gateway.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/etcdmain/gateway.go b/etcdmain/gateway.go index b348fb14b..55fd2e56b 100644 --- a/etcdmain/gateway.go +++ b/etcdmain/gateway.go @@ -17,6 +17,7 @@ package etcdmain import ( "fmt" "net" + "net/url" "os" "time" @@ -77,6 +78,20 @@ func newGatewayStartCommand() *cobra.Command { return &cmd } +func stripSchema(eps []string) []string { + var endpoints []string + + for _, ep := range eps { + + if u, err := url.Parse(ep); err == nil && u.Host != "" { + ep = u.Host + } + + endpoints = append(endpoints, ep) + } + + return endpoints +} func startGateway(cmd *cobra.Command, args []string) { endpoints := gatewayEndpoints if gatewayDNSCluster != "" { @@ -101,6 +116,9 @@ func startGateway(cmd *cobra.Command, args []string) { } } + // Strip the schema from the endpoints because we start just a TCP proxy + endpoints = stripSchema(endpoints) + if len(endpoints) == 0 { plog.Fatalf("no endpoints found") }