Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shrinking of prioritized paths #736

Merged
merged 1 commit into from
Feb 17, 2021
Merged

Conversation

jcmoraisjr
Copy link
Owner

HAProxy Ingress since v0.11 implements path types other then begin (the one from v0.10 and olders) and some sort of regex (when a regex alias or a wildcard hostname is used) since v0.11. Now we have full regex (may be used in the path of ingress spec), exact and prefix - respectively str and dir from haproxy acl. This also fits ingress v1 spec.

Up to v0.11.1, overlapping paths were being wrongly routed depending on the path type they use. This happens because haproxy doesn't have a common list where all the path types can be matched, but instead distinct maps that does distinct matches. We were matching exact first, followed by prefix, then begin and so regex. The first map with a match wins. But this would lead to wrong routes if eg one have /api as prefix and /api/sub as begin - a request with /api/sub would wrongly match /api in the prefix map.

v0.11.2 fixes this behavior looking for overlaps and creating extra map files if necessary, and move priority matches to it, so in the former example haproxy would match /api/sub first, and only after that would try to match /api. v0.11.2 however introduced a bug: the wrong path might be removed from the old map, depending on the order and state of the other paths in that map. This commit fixes how the internal array of paths is changed, and now it removes only the right one.

Should be merged as far as v0.11 where the functionality was first implemented.

HAProxy Ingress since v0.11 implements path types other then `begin`
(the one from v0.10 and olders) and some sort of `regex` (when a regex
alias or a wildcard hostname is used) since v0.11. Now we have full
`regex` (may be used in the path of ingress spec), `exact` and `prefix`
- respectively str and dir from haproxy acl. This also fits ingress v1
spec.

Up to v0.11.1, overlapping paths were being wrongly routed depending on
the path type they use. This happens because haproxy doesn't have a
common list where all the path types can be matched, but instead
distinct maps that does distinct matches. We were matching `exact`
first, followed by `prefix`, then `begin` and so `regex`. The first
map with a match wins. But this would lead to wrong routes if eg one
have `/api` as prefix and `/api/sub` as begin - a request with
`/api/sub` would wrongly match `/api` in the prefix map.

v0.11.2 fixes this behavior looking for overlaps and creating extra
map files if necessary, and move priority matches to it, so in the
former example haproxy would match `/api/sub` first, and only after that
would try to match `/api`. v0.11.2 however introduced a bug: the wrong
path might be removed from the old map, depending on the order and state
of the other paths in that map. This commit fixes how the internal
array of paths is changed, and now it removes only the right one.

Should be merged as far as v0.11 where the functionality was first
implemented.
@jcmoraisjr
Copy link
Owner Author

#733

@jcmoraisjr jcmoraisjr merged commit dd2bba4 into master Feb 17, 2021
@jcmoraisjr jcmoraisjr deleted the jm-fix-shrink-paths branch February 17, 2021 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant