Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gateway: fix the dns discovery method #7454

Merged
merged 1 commit into from
Mar 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions etcdmain/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package etcdmain
import (
"fmt"
"net"
"net/url"
"os"
"time"

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

func stripSchema(eps []string) []string {
Copy link
Member

@fanminshi fanminshi Mar 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add unit tests for this function? I would like to increase the etcd coverage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the discovery stuff should eventually be covered by e2e tests; I don't think a unit test is necessary here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdudelsack heyitsanthony is right about not having the unit test. The test path should be covered in e2e test where the correct behavior gateway should be verified. Sorry for the wrong suggestion.

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 != "" {
Expand All @@ -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")
}
Expand Down