grpc / grpc-go

The Go language implementation of gRPC. HTTP/2 based RPC

Home Page:https://grpc.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is dynamic routing currently supported in grpc-go or how can i achieve it?

EndlessSeeker opened this issue · comments

I would like to ask, is the dynamic routing function for a request currently supported?
For example, I specified that the target service is a in the client dial, but I hope that during actual request, the client can dynamically call the service b, c or even specific ip:port of service a according to some rules. I hope that users of the framework will be unaware of this logic.
How can I implement the above function? At present, I think it may be possible to achieve it by customizing a Resolver. Is this feasible? Or is there a more recommended way?

The best way to go about this would be to use xDS and a management server that has the configuration as per the "rules". You could also achieve this using a Custom Resolver - but it would be static and a client upgrade would be in order to change the routing logic. Using a xDS management server gives you the dynamic Out of Band routing you might be looking for.

See: https://github.com/grpc/grpc-go/tree/master/examples/features/xds

Thanks for your suggestion!
Follow your suggestions, I deployed a grpc server and istio in k8s, and a grpc client will access the grpc server in my mac. However, I found that the client seemed to have an exception in parsing lds (The specific method of printing logs is in xds/xdsclient/authority.go::decodeAllResources). The result of this is that if the xds:/// prefix is ​​used, the call will time out
The grpc-go version is 1.62.x, and the istio version is 1.20.3. I would like to ask if we have any restrictions on the istio version?

[decodeAllResources] name: 10.0.0.10_53, result: &{Name:10.0.0.10_53 Resource:0x14000099260}, err: network filters {[name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"} name:"envoy.filters.network.tcp_proxy" typed_config:{type_url:"type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy" value:"\n3outbound|53||kube-dns.kube-system.svc.cluster.local\x123outbound|53||kube-dns.kube-system.svc.cluster.local"}]} has unsupported network filter "type.googleapis.com/stats.PluginConfig" in filter {name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"}}
[decodeAllResources] name: 10.0.159.201_80, result: &{Name:10.0.159.201_80 Resource:0x14000099320}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 10.0.112.177_15021, result: &{Name:10.0.112.177_15021 Resource:0x140000993e0}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 0.0.0.0_80, result: &{Name:0.0.0.0_80 Resource:0x140000994a0}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 10.0.211.31_80, result: &{Name:10.0.211.31_80 Resource:0x14000099560}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 0.0.0.0_15014, result: &{Name:0.0.0.0_15014 Resource:0x14000099620}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 10.0.0.1_443, result: &{Name:10.0.0.1_443 Resource:0x140000996e0}, err: network filters {[name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"} name:"envoy.filters.network.tcp_proxy" typed_config:{type_url:"type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy" value:"\n2outbound|443||kubernetes.default.svc.cluster.local\x122outbound|443||kubernetes.default.svc.cluster.local"}]} has unsupported network filter "type.googleapis.com/stats.PluginConfig" in filter {name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"}}
[decodeAllResources] name: 10.0.220.75_8848, result: &{Name:10.0.220.75_8848 Resource:0x140000997a0}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 10.0.208.25_20001, result: &{Name:10.0.208.25_20001 Resource:0x14000099860}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 10.0.1.252_80, result: &{Name:10.0.1.252_80 Resource:0x14000099920}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 10.0.130.20_443, result: &{Name:10.0.130.20_443 Resource:0x140000999e0}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 10.0.245.146_15012, result: &{Name:10.0.245.146_15012 Resource:0x14000099aa0}, err: network filters {[name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"} name:"envoy.filters.network.tcp_proxy" typed_config:{type_url:"type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy" value:"\n5outbound|15012||istiod.istio-system.svc.cluster.local\x125outbound|15012||istiod.istio-system.svc.cluster.local"}]} has unsupported network filter "type.googleapis.com/stats.PluginConfig" in filter {name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"}}
[decodeAllResources] name: 10.0.245.146_443, result: &{Name:10.0.245.146_443 Resource:0x14000099b60}, err: network filters {[name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"} name:"envoy.filters.network.tcp_proxy" typed_config:{type_url:"type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy" value:"\n3outbound|443||istiod.istio-system.svc.cluster.local\x123outbound|443||istiod.istio-system.svc.cluster.local"}]} has unsupported network filter "type.googleapis.com/stats.PluginConfig" in filter {name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"}}
[decodeAllResources] name: 10.0.0.10_9153, result: &{Name:10.0.0.10_9153 Resource:0x14000099c20}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 192.168.41.1_10250, result: &{Name:192.168.41.1_10250 Resource:0x14000099ce0}, err: network filters {[name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"} name:"envoy.filters.network.tcp_proxy" typed_config:{type_url:"type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy" value:"\n5outbound|10250||kubelet.kube-system.svc.cluster.local\x125outbound|10250||kubelet.kube-system.svc.cluster.local"}]} has unsupported network filter "type.googleapis.com/stats.PluginConfig" in filter {name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"}}
[decodeAllResources] name: 10.0.220.75_9848, result: &{Name:10.0.220.75_9848 Resource:0x14000099da0}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 10.0.145.146_80, result: &{Name:10.0.145.146_80 Resource:0x14000099e60}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 10.0.112.177_443, result: &{Name:10.0.112.177_443 Resource:0x14000099f20}, err: network filters {[name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"} name:"envoy.filters.network.tcp_proxy" typed_config:{type_url:"type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy" value:"\nAoutbound|443||istio-ingressgateway.istio-system.svc.cluster.local\x12Aoutbound|443||istio-ingressgateway.istio-system.svc.cluster.local"}]} has unsupported network filter "type.googleapis.com/stats.PluginConfig" in filter {name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"}}
[decodeAllResources] name: 10.0.172.54_3306, result: &{Name:10.0.172.54_3306 Resource:0x140001a4180}, err: network filters {[name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"} name:"envoy.filters.network.tcp_proxy" typed_config:{type_url:"type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy" value:"\n4outbound|3306||demo-mysql.mse-demo.svc.cluster.local\x124outbound|3306||demo-mysql.mse-demo.svc.cluster.local"}]} has unsupported network filter "type.googleapis.com/stats.PluginConfig" in filter {name:"istio.stats" typed_config:{type_url:"type.googleapis.com/stats.PluginConfig"}}
[decodeAllResources] name: 10.0.239.31_20002, result: &{Name:10.0.239.31_20002 Resource:0x140001a4240}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 10.0.194.156_20003, result: &{Name:10.0.194.156_20003 Resource:0x140001a4360}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: 0.0.0.0_15010, result: &{Name:0.0.0.0_15010 Resource:0x140001a4480}, err: unsupported field 'listener_filters' contains 2 entries
[decodeAllResources] name: virtualOutbound, result: &{Name:virtualOutbound Resource:0x140001a4540}, err: unsupported field 'use_original_dst' is present and set to true
[decodeAllResources] name: virtualInbound, result: &{Name:virtualInbound Resource:0x140001a4600}, err: unsupported field 'listener_filters' contains 3 entries

I found that this code caused that the lds data returned by istio can not be parsed. May I ask why it is designed like this? Is it necessary to optimize here, because it is normal for lds to carry listener filter info now?
path: xds/internal/xdsclient/xdsresource/unmarshal_lds.go::processServerSideListener

func processServerSideListener(lis *v3listenerpb.Listener) (*ListenerUpdate, error) {
	if n := len(lis.ListenerFilters); n != 0 {
		return nil, fmt.Errorf("unsupported field 'listener_filters' contains %d entries", n)
	}
        ...

I tried many ways, even modified the code, but still couldn't get through the xds client. Regarding the sample given, is there a bootstrap.json file that can be used for my reference?

@EndlessSeeker -

From the logs, the code path that was likely invoked if you are using a xDS enabled gRPC server. And based on your initial question I dont think this is what you need. You would need the client to be using xDS.

Also regarding this, that particular scenario is called out in in gRFC A36 - xDS for servers, and talks about NACKing when listener filters are present. See: https://github.com/grpc/proposal/blob/ea5552587c5b93e978c4bcb695e2210ff97ccbf8/A36-xds-for-servers.md?plain=1#L160

This issue is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed.

yes, i need use xDS in client scenarios. Maybe I'm using it incorrectly, but I didn't find the correct way to use it...It would be nice if the xds example has the instruction about bootstrap file. I guess my bootstrap is not written correctly.