Identifier does not return on first successful match
See original GitHub issueAccording to linkerd docs: https://linkerd.io/config/1.0.0/linkerd/index.html#http-1-1-identifiers
If a list of identifiers is provided, each identifier is tried in turn until one successfully assigns a logical name to the request.
If I have a list of identifier as:
routers:
- protocol: http
identifier:
kind: io.l5d.header.token
header: Custom-Header
identifier:
kind: io.l5d.path
segments: 1
consume: true
I would expect linkerd to return if the Custom-Header is included in the request and a match is made (not try path identifier). Currently I am seeing linkerd still try to route the service to the constructed path when the header is included.
$ http GET linkerd:4140/api/v1/hello Custom-Header:hello-world
HTTP/1.1 502 Bad Gateway
Content-Encoding: gzip
Content-Length: 106
Content-Type: text/plain
l5d-err: No+hosts+are+available+for+%2Fsvc%2Fapi%2C+Dtab.base%3D%5B%5D%2C+Dtab.local%3D%5B%5D.+Remote+Info%3A+Not+Available
No hosts are available for /svc/api, Dtab.base=[], Dtab.local=[]. Remote Info: Not Available
The service works correctly when I try to use the path identifier with and without the header.
If I reverse the order of the identifiers in the config I get a different error when using only path identifier with no Custom-Header:
Unknown Destination: Request("GET /hello-world/api/v1/hello", from /x.x.x.x:xxxx) / Custom-Header is absent.
Is this expected behavior?
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
Yes, that will use the header if it is present and fall back to the path otherwise.
You have the
identifier
property set twice in your linkerd config which will cause the first identifier to be overriden/replaced by the second one. Instead, you should provide a list of identifiers:The difference is pretty subtle. I’ve filed https://github.com/linkerd/linkerd/issues/1262 to make it so that duplicate properties will raise an error.