edsbalancer: fix address format (#2675)

This commit is contained in:
lyuxuan
2019-03-08 15:17:55 -08:00
committed by GitHub
parent 5abb35752c
commit 29adad9d71

View File

@ -21,7 +21,9 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net"
"reflect" "reflect"
"strconv"
"sync" "sync"
xdspb "github.com/envoyproxy/go-control-plane/envoy/api/v2" xdspb "github.com/envoyproxy/go-control-plane/envoy/api/v2"
@ -206,7 +208,7 @@ func (xdsB *EDSBalancer) HandleEDSResponse(edsResp *xdspb.ClusterLoadAssignment)
for _, lbEndpoint := range locality.GetLbEndpoints() { for _, lbEndpoint := range locality.GetLbEndpoints() {
socketAddress := lbEndpoint.GetEndpoint().GetAddress().GetSocketAddress() socketAddress := lbEndpoint.GetEndpoint().GetAddress().GetSocketAddress()
newAddrs = append(newAddrs, resolver.Address{ newAddrs = append(newAddrs, resolver.Address{
Addr: fmt.Sprintf("%s:%d", socketAddress.GetAddress(), socketAddress.GetPortValue()), Addr: net.JoinHostPort(socketAddress.GetAddress(), strconv.Itoa(int(socketAddress.GetPortValue()))),
}) })
} }
var weightChanged, addrsChanged bool var weightChanged, addrsChanged bool