之前测试使用的路由配置host有问题,没有加namespace,所以路由功能没有生效,按照下面的配置修改后又重新做了测试:
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: dubbo-xds-test-vs
namespace: dubbo-demo
spec:
hosts:
- dubbo-samples-xds-provider.dubbo-demo.svc.cluster.local
http:
- route:
- destination:
host: dubbo-samples-xds-provider.dubbo-demo.svc.cluster.local
subset: v1
port:
number: 50051
weight: 50
- destination:
host: dubbo-samples-xds-provider.dubbo-demo.svc.cluster.local
subset: v2
port:
number: 50051
weight: 50
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: dubbo-xds-test-dr
namespace: dubbo-demo
spec:
host: dubbo-samples-xds-provider.dubbo-demo.svc.cluster.local
trafficPolicy:
loadBalancer:
# Envoy load balancing strategy
simple: ROUND_ROBIN
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
调用provider直接失败,报错信息如下:
WARNING: [DUBBO] No provider available after route for the service org.apache.dubbo.samples.api.GreetingService:1.0.0 from registry 10.244.0.252 on the consumer 10.244.0.252 using the dubbo version 1.0-SNAPSHOT. Router snapshot is below:
[ Parent (Input: 0) (Current Node Output: 0) (Chain Node Output: 0) ] Input: Empty -> Chain Node Output: Empty
[ MockInvokersSelector (Input: 0) (Current Node Output: 0) (Chain Node Output: 0) Router message: Empty invokers. Directly return. ] Current Node Output: Empty, dubbo version: 1.0-SNAPSHOT, current host: 10.244.0.252, error code: 2-2. This may be caused by No provider available after route for the service, go to https://dubbo.apache.org/faq/2/2 to find instructions.
Mar 15, 2023 6:59:21 AM org.apache.dubbo.rpc.cluster.directory.AbstractDirectory warn
WARNING: [DUBBO] No provider available after connectivity filter for the service org.apache.dubbo.samples.api.GreetingService:1.0.0 All validInvokers' size: 0 All routed invokers' size: 0 All invokers' size: 0 from registry istiod.istio-system.svc:15012 on the consumer 10.244.0.252 using the dubbo version 1.0-SNAPSHOT., dubbo version: 1.0-SNAPSHOT, current host: 10.244.0.252, error code: 2-2. This may be caused by provider server or registry center crashed, go to https://dubbo.apache.org/faq/2/2 to find instructions.
org.apache.dubbo.rpc.RpcException: Failed to invoke the method sayHello in the service org.apache.dubbo.samples.api.GreetingService. No provider available for the service org.apache.dubbo.samples.api.GreetingService:1.0.0 from registry istiod.istio-system.svc:15012 on the consumer 10.244.0.252 using the dubbo version 1.0-SNAPSHOT. Please check if the providers have been started and registered.
at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.checkInvokers(AbstractClusterInvoker.java:367)
at org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:60)
at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:341)
at org.apache.dubbo.rpc.cluster.router.RouterSnapshotFilter.invoke(RouterSnapshotFilter.java:46)
at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327)
at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:101)
at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327)
at org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:52)
at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327)
at org.apache.dubbo.spring.security.filter.ContextHolderParametersSelectedTransferFilter.invoke(ContextHolderParametersSelectedTransferFilter.java:41)
at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327)
at org.apache.dubbo.rpc.cluster.filter.support.ConsumerClassLoaderFilter.invoke(ConsumerClassLoaderFilter.java:40)
at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327)
at org.apache.dubbo.rpc.cluster.filter.support.ConsumerContextFilter.invoke(ConsumerContextFilter.java:118)
at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327)
at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CallbackRegistrationInvoker.invoke(FilterChainBuilder.java:194)
at org.apache.dubbo.rpc.cluster.support.wrapper.AbstractCluster$ClusterFilterInvoker.invoke(AbstractCluster.java:92)
at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:103)
at org.apache.dubbo.registry.client.migration.MigrationInvoker.invoke(MigrationInvoker.java:282)
at org.apache.dubbo.rpc.proxy.InvocationUtil.invoke(InvocationUtil.java:56)
at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:75)
at org.apache.dubbo.samples.api.GreetingServiceDubboProxy0.sayHello(GreetingServiceDubboProxy0.java)
at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy27.sayHello(Unknown Source)
at org.apache.dubbo.samples.action.GreetingServiceConsumer.doSayHello(GreetingServiceConsumer.java:34)
at org.apache.dubbo.samples.ConsumerBootstrap.main(ConsumerBootstrap.java:38)
看起来像是通过路由配置找到注册的provider示例,但是我这边确实能查到启动的两个provider实例:
# kubectl describe svc dubbo-samples-xds-provider -n dubbo-demo
Name: dubbo-samples-xds-provider
Namespace: dubbo-xds-demo
Labels: <none>
Annotations: <none>
Selector: app=dubbo-samples-xds-provider
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: None
IPs: None
Port: grpc 50051/TCP
TargetPort: 50051/TCP
Endpoints: 10.244.0.253:50051,10.244.0.254:50051
Session Affinity: None
Events: <none>