Repository navigation
Closed
Labels
questionQuestions that are neither investigations, bugs, nor enhancements
Description
Title: route.HeaderMatcher present_match is invalid
Description:
I tried to use HeaderMatch in the routing configuration, the request header name is
x-ams-namespace. Whether I set present_match true or false, it only filters requests that havex-ams-namespace. If there is nox-ams-namespacein the header, the envoy log shows no match cluster
Repro steps:
the environment
- envoyproxy/envoy:v1.13.0 in docker
Config:
here is my route config
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match:
prefix: "/ams.demo.HelloWorldService"
grpc: {}
headers:
- name: "x-ams-namespace"
present_match: false
route:
cluster: default-service
Logs:
this is the log containing the x-ams-namespace request header
[2020-02-18 02:20:54.192][12][debug][http] [source/common/http/conn_manager_impl.cc:731] [C0][S9768922037303758833] request headers complete (end_stream=false):
':path', '/ams.demo.HelloWorldService/SayHello'
':method', 'POST'
':scheme', 'https'
'content-type', 'application/grpc'
'te', 'trailers'
'user-agent', 'grpc-java-netty/1.27.0'
'x-ams-namespace', 't2est'
'grpc-accept-encoding', 'gzip'
'grpc-timeout', '999706u'
[2020-02-18 02:20:54.192][12][debug][router] [source/common/router/router.cc:474] [C0][S9768922037303758833] cluster 'default-service' match for URL '/ams.demo.HelloWorldService/SayHello'
[2020-02-18 02:20:54.192][12][debug][router] [source/common/router/router.cc:614] [C0][S9768922037303758833] router decoding headers:
this is the log that does not contain the x-ams-namespace request header
[2020-02-18 02:20:57.938][12][debug][http] [source/common/http/conn_manager_impl.cc:731] [C1][S2265561003369121236] request headers complete (end_stream=false):
':path', '/ams.demo.HelloWorldService/SayHello'
':method', 'POST'
':scheme', 'https'
'content-type', 'application/grpc'
'te', 'trailers'
'user-agent', 'grpc-java-netty/1.27.0'
'grpc-accept-encoding', 'gzip'
'grpc-timeout', '999638u'
[2020-02-18 02:20:57.938][12][debug][router] [source/common/router/router.cc:412] [C1][S2265561003369121236] no cluster match for URL '/ams.demo.HelloWorldService/SayHello'
[2020-02-18 02:20:57.938][12][debug][http] [source/common/http/conn_manager_impl.cc:1417] [C1][S2265561003369121236] Sending local reply with details route_not_found
Reacted by Eric Sirianni and Chris Brawn
Metadata
Metadata
Assignees
Labels
questionQuestions that are neither investigations, bugs, nor enhancements
Activity
lizan commentedon Feb 18, 2020
Is
invert_matchwhat you want? try:wcmolin commentedon Feb 18, 2020
@lizan
forgive my poor english.
your suggestion is useful, but I don't want to use
invert_match, justpresent_match.I tried to set
present_matchto true, and then a request with a header'x-ams-namespace'matched to the cluster. Next, I changedpresent_matchto false, restarted the envoy, and again sent a request with the same header, but it still matched to the cluster. Why didpresent_matchset totrueandfalsegive the same resultlizan commentedon Feb 18, 2020
@wcmolin because the configuration language protobuf doesn't differentiate whether a bool is not set or false, so
present_match: falseis a no-op. As documented in https://www.envoyproxy.io/docs/envoy/latest/api-v2/api/v2/route/route_components.proto#route-headermatcher, by default the header matcher will be performed aspresent_match, because no other match are set.wcmolin commentedon Feb 18, 2020
ok, thanks