diff --git a/grpclb_remote_balancer.go b/grpclb_remote_balancer.go index 11305e833d79..950222a7eb75 100644 --- a/grpclb_remote_balancer.go +++ b/grpclb_remote_balancer.go @@ -176,13 +176,13 @@ func (lb *lbBalancer) sendLoadReport(s *balanceLoadClientStream, interval time.D } } -func (lb *lbBalancer) callRemoteBalancer() (_ error, backoff bool) { +func (lb *lbBalancer) callRemoteBalancer() (backoff bool, _ error) { lbClient := &loadBalancerClient{cc: lb.ccRemoteLB} ctx, cancel := context.WithCancel(context.Background()) defer cancel() stream, err := lbClient.BalanceLoad(ctx, FailFast(false)) if err != nil { - return fmt.Errorf("grpclb: failed to perform RPC to the remote balancer %v", err), true + return true, fmt.Errorf("grpclb: failed to perform RPC to the remote balancer %v", err) } // grpclb handshake on the stream. @@ -194,18 +194,18 @@ func (lb *lbBalancer) callRemoteBalancer() (_ error, backoff bool) { }, } if err := stream.Send(initReq); err != nil { - return fmt.Errorf("grpclb: failed to send init request: %v", err), true + return true, fmt.Errorf("grpclb: failed to send init request: %v", err) } reply, err := stream.Recv() if err != nil { - return fmt.Errorf("grpclb: failed to recv init response: %v", err), true + return true, fmt.Errorf("grpclb: failed to recv init response: %v", err) } initResp := reply.GetInitialResponse() if initResp == nil { - return fmt.Errorf("grpclb: reply from remote balancer did not include initial response"), true + return true, fmt.Errorf("grpclb: reply from remote balancer did not include initial response") } if initResp.LoadBalancerDelegate != "" { - return fmt.Errorf("grpclb: Delegation is not supported"), true + return true, fmt.Errorf("grpclb: Delegation is not supported") } go func() { @@ -214,13 +214,13 @@ func (lb *lbBalancer) callRemoteBalancer() (_ error, backoff bool) { } }() // No backoff if init req/resp handshake was successful. - return lb.readServerList(stream), false + return false, lb.readServerList(stream) } func (lb *lbBalancer) watchRemoteBalancer() { var retryCount int for { - err, doBackoff := lb.callRemoteBalancer() + doBackoff, err := lb.callRemoteBalancer() select { case <-lb.doneCh: return