Venkat-C-J commented on issue #2822:
URL:
https://github.com/apache/apisix-ingress-controller/issues/2822#issuecomment-5191467962
Thanks for the detailed analysis — you're right that the service-level
fallback exists and works, and your reproduction is correct. I was able to
narrow this down further, and I think that's precisely why it didn't reproduce:
the trigger is an uppercase character in the hostname.
apisix/router.lua's filter() lowercases route hosts:
elseif route.value.hosts then
for i, v in ipairs(route.value.hosts) do
route.value.hosts[i] = str_lower(v)
end
end
apisix/http/service.lua's filter() has no equivalent — service.value.hosts
is stored verbatim. Since matching is done against nginx $host (always
lowercase) via a case-sensitive reversed-string radixtree bucket, a host like
MixedCase.example.com on a service produces a bucket key no request can ever
reach.
Before 2.1.0, buildRoute set route.Hosts = rule.Match.Hosts, so the value
was normalized by router.lua. After PR #2743 removed that line, the host
constraint travels only on the service and is never lowercased — so every route
for a mixed-case host becomes unreachable and falls through to a 404. Lowercase
hosts are unaffected, which is why your tenant-a.example.com repro passes.
Minimal repro (should fail on 2.1.0, pass on 2.0.1):
# ApisixRoute A
match:
hosts: ["MixedCase.example.com"] # uppercase
paths: ["/*"]
# ApisixRoute B
match:
hosts: ["lowercase.example.com"]
paths: ["/*"]
curl -H 'Host: MixedCase.example.com' ... → 404 on 2.1.0, 200 on 2.0.1. The
lowercase host works on both. Inspecting /apisix/admin/routes shows no hosts on
the route object under 2.1.0, and /apisix/admin/services shows the host
preserved with its original casing.
We reproduce this on APISIX 3.16 + ADC 0.27 and APISIX 3.17 + ADC 0.28; both
combinations pass with ingress-controller 2.0.1 and identical CRDs, so the
controller version is the only variable.
Two questions:
1.
Would you agree the cleanest fix is restoring route.Hosts = rule.Match.Hosts
(with any ADC diff noise handled by normalization in the diff layer instead)?
2.
Independently, should service.lua's filter() lowercase service.value.hosts
to match router.lua, so the two paths are genuinely equivalent? Right now the
schema accepts uppercase hosts ([0-9a-zA-Z-.\[\]:]) but they're silently
unroutable when they only appear on a service.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]