Skip to content
Snippets Groups Projects
Unverified Commit 63ce222d authored by Xin.Zh's avatar Xin.Zh Committed by GitHub
Browse files

Merge pull request #851 from cvictory/local_fix_health_check_no_provider

Fix : when there is no invoker is available, we should return "No Provider Available" Error.
parents 22107248 553ea9e4
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/protocol"
)
......@@ -119,6 +120,10 @@ func (invoker *baseClusterInvoker) doSelect(lb cluster.LoadBalance, invocation p
}
func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invocation protocol.Invocation, invokers []protocol.Invoker, invoked []protocol.Invoker) protocol.Invoker {
if len(invokers) == 0 {
logger.Errorf("the invokers of %s is nil. ", invocation.Invoker().GetUrl().ServiceKey())
return nil
}
if len(invokers) == 1 {
return invokers[0]
}
......@@ -133,6 +138,8 @@ func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invoc
for _, invoker := range invokers {
if !invoker.IsAvailable() {
logger.Infof("the invoker of %s is not available, maybe some network error happened or the server is shutdown.",
invoker.GetUrl().Ip)
continue
}
......@@ -144,6 +151,7 @@ func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invoc
if len(reslectInvokers) > 0 {
selectedInvoker = lb.Select(reslectInvokers, invocation)
} else {
logger.Errorf("all %d invokers is unavailable for %s.", len(invokers), selectedInvoker.GetUrl().String())
return nil
}
}
......
......@@ -51,6 +51,7 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr
result protocol.Result
invoked []protocol.Invoker
providers []string
ivk protocol.Invoker
)
invokers := invoker.directory.List(invocation)
......@@ -75,7 +76,7 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr
return &protocol.RPCResult{Err: err}
}
}
ivk := invoker.doSelect(loadBalance, invocation, invokers, invoked)
ivk = invoker.doSelect(loadBalance, invocation, invokers, invoked)
if ivk == nil {
continue
}
......@@ -88,10 +89,17 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr
}
return result
}
ip := common.GetLocalIp()
invokerSvc := invoker.GetUrl().Service()
invokerUrl := invoker.directory.GetUrl()
if ivk == nil {
logger.Errorf("Failed to invoke the method %s of the service %s .No provider is available.", methodName, invokerSvc)
return &protocol.RPCResult{
Err: perrors.Errorf("Failed to invoke the method %s of the service %s .No provider is available because can't connect server.",
methodName, invokerSvc),
}
}
return &protocol.RPCResult{
Err: perrors.Wrap(result.Error(), fmt.Sprintf("Failed to invoke the method %v in the service %v. "+
"Tried %v times of the providers %v (%v/%v)from the registry %v on the consumer %v using the dubbo version %v. "+
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment