-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
sort category.apis_by_methods to fix a routing problem #2523
Conversation
…ed with method and path
98ef9d8
to
6193124
Compare
Some of the tests seem to fail randomly due to variation of network connectivity condition to external endpoints, not due to changes made in this PR. This PR has been validated manually with the case described in issue #2522 |
Hi, Thanks for looking into this. Could you provide regression tests for this? They exist in both unit and integration suites. Manually validated is not enough... Thank you! |
thanks for the feedback. will make another commit for tests. |
5716e14
to
5ca51f6
Compare
@thibaultcha can you take a look again or assign to proper reviewer? The travis test failure seems to be caused by |
Please ignore the build failures, we'll take care of those. This will be reviewed when we'll have some time. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
Thanks for spotting this. So, I gave it a try on my side, and I can see that the same scenario happens, when defining an API with uris and plain hosts (not methods). This is related to the same underlying issue: the lack of sorting for category.apis_by_plain_hosts
. Would you be willing to update this patch so as to handle this edge-case as well?
kong/core/router.lua
Outdated
@@ -433,30 +433,38 @@ function _M.new(apis) | |||
categorize_api_t(api_t, categories) | |||
end | |||
|
|||
local compare = function(a,b, category_bit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: missing a space after the first argument a,
. We also favor declaration of local function with the following form:
local function compare(a, b, category_bit)
end
@@ -390,7 +390,7 @@ describe("Router", function() | |||
end) | |||
end) | |||
end) | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like an undesired change
api_t = router.select("GET", "/my-api/world") | ||
assert.truthy(api_t) | ||
assert.same(use_case[1], api_t.api) | ||
end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need the same test for APIs defined with both a URI and a plain host.
Thanks @thibaultcha . Will do another commit to address comments and add sorting to the case of |
@leonzz Great, thank you. Ultimately, this fix should belong to the same commit, as it is the same issue.
Definitely! That sounds like a good discussion to have on the Kong mailing list :) |
yep agree that they should be one commit. do you want me to put them together and do a force update on this branch? |
Merged to master with a few minor edits, thank you very much for the issue + the fix! |
Summary
Sort category.apis_by_methods in router.lua to fix a routing problem for APIs defined with method and uri (path)
Full changelog
Issues resolved
Fix #2522