Skip to content

Commit

Permalink
gateway: fix the dns discovery method
Browse files Browse the repository at this point in the history
strip the scheme from the endpoints to have a clean hostname for TCP proxy

Fixes #7452
  • Loading branch information
bdudelsack committed Mar 8, 2017
1 parent 320768b commit d272f4a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions etcdmain/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/coreos/etcd/pkg/transport"
"github.com/coreos/etcd/proxy/tcpproxy"
"github.com/spf13/cobra"
"strings"
)

var (
Expand Down Expand Up @@ -77,6 +78,23 @@ func newGatewayStartCommand() *cobra.Command {
return &cmd
}

func stripSchema(eps []string) []string {
var endpoints []string

for _, ep := range eps {

if strings.HasPrefix(ep, "https://") {
ep = ep[len("https://"):]
} else if strings.HasPrefix(ep, "http://") {
ep = ep[len("http://"):]
}

endpoints = append(endpoints, ep)
}

return endpoints
}

func startGateway(cmd *cobra.Command, args []string) {
endpoints := gatewayEndpoints
if gatewayDNSCluster != "" {
Expand All @@ -101,6 +119,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")
}
Expand Down

0 comments on commit d272f4a

Please sign in to comment.