Revert "Strip port from server name in grpclb (#2066)" (#2083)

This reverts commit d24d0a4b993587a34ac7d09ac956b0375ee7d1fa.
This commit is contained in:
Menghan Li
2018-05-16 15:37:34 -07:00
committed by GitHub
parent 4e829f028a
commit 1bacc35978
2 changed files with 2 additions and 24 deletions

View File

@ -19,7 +19,6 @@
package grpc
import (
"net"
"strconv"
"strings"
"sync"
@ -127,16 +126,6 @@ func (b *lbBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions) bal
target = targetSplitted[1]
}
// Remove port number from target if it exists.
if host, _, err := net.SplitHostPort(target); err == nil {
// When err is not nil, target remains unchanged.
//
// Possible non-nil err values:
// - missing port in address: no port to strip
// - other errors: failed to parse
target = host
}
lb := &lbBalancer{
cc: newLBCacheClientConn(cc),
target: target,

View File

@ -313,7 +313,7 @@ func newLoadBalancer(numberOfBackends int) (tss *testServers, cleanup func(), er
return
}
func testGRPCLBSimple(t *testing.T, target string) {
func TestGRPCLB(t *testing.T) {
defer leakcheck.Check(t)
r, cleanup := manual.GenerateAndRegisterManualResolver()
@ -341,7 +341,7 @@ func testGRPCLBSimple(t *testing.T, target string) {
}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
cc, err := grpc.DialContext(ctx, r.Scheme()+":///"+target,
cc, err := grpc.DialContext(ctx, r.Scheme()+":///"+beServerName,
grpc.WithTransportCredentials(&creds), grpc.WithDialer(fakeNameDialer))
if err != nil {
t.Fatalf("Failed to dial to the backend %v", err)
@ -360,17 +360,6 @@ func testGRPCLBSimple(t *testing.T, target string) {
}
}
func TestGRPCLB(t *testing.T) {
testGRPCLBSimple(t, beServerName)
}
// TestGRPCLBWithPort is same as TestGRPCLB, expect that the dialing target
// contains fake port number ":8080". The purpose of this test is to make sure
// that grpclb strips port number from the dialing target in init request.
func TestGRPCLBWithPort(t *testing.T) {
testGRPCLBSimple(t, beServerName+":8080")
}
// The remote balancer sends response with duplicates to grpclb client.
func TestGRPCLBWeighted(t *testing.T) {
defer leakcheck.Check(t)