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

Intermittent "405 Method Not Allowed" #759

Closed
guy-otonomo opened this issue Dec 9, 2022 · 2 comments
Closed

Intermittent "405 Method Not Allowed" #759

guy-otonomo opened this issue Dec 9, 2022 · 2 comments

Comments

@guy-otonomo
Copy link

guy-otonomo commented Dec 9, 2022

Update - issues identified in own code (custom endpoints' schema contained nil). Closing this.

We use lapis as part of Kong, as we extend Kong's Admin API.
With our current Kong 1.2.1 and kong-lapis/1.6.0.1-1, everything works fine.

With newer Kong and kong-lapis/1.8.3.1-1 we get this behavior:
Sometimes when Kong starts, the endpoints we define are returning 405 - Method not allowed error.
We can restart Kong and it might - and might not - solve the issue.
(See this bug for reference).

I wonder what can cause it?
How can we debug this?
I would like to see all the routes that lapis recognizes (like after Kong registers our API), or see debug logs how lapis searches its config upon an HTTP request.

I will be happy to provide any data needed.

Update: when the call fails, it is actually happens from here:

return error("don't know how to respond to " .. tostring(self.req.cmd_mth))

Update2: iterating over tbl when lapis gets the /groups request, and indeed, there is no 'GET' method:

for k,v in pairs(tbl) do
  print("k= " .. k)
  print("v= " .. v)
end
2022/12/10 16:31:03 [notice] 14434#0: *71990 [lua] application.lua:384: k= OPTIONS, client: 127.0.0.1, server: kong_admin, request: "GET /groups HTTP/1.1", host: "localhost:8001"
2022/12/10 16:31:03 [notice] 14434#0: *71990 [lua] application.lua:385: v= function: 0x402f57a4f8, client: 127.0.0.1, server: kong_admin, request: "GET /groups HTTP/1.1", host: "localhost:8001"
2022/12/10 16:31:03 [notice] 14434#0: *71990 [lua] application.lua:384: k= HEAD, client: 127.0.0.1, server: kong_admin, request: "GET /groups HTTP/1.1", host: "localhost:8001"
2022/12/10 16:31:03 [notice] 14434#0: *71990 [lua] application.lua:385: v= function: 0x402ae63858, client: 127.0.0.1, server: kong_admin, request: "GET /groups HTTP/1.1", host: "localhost:8001"
2022/12/10 16:31:03 [notice] 14434#0: *71990 [lua] application.lua:384: k= methods, client: 127.0.0.1, server: kong_admin, request: "GET /groups HTTP/1.1", host: "localhost:8001"
2022/12/10 16:31:03 [notice] 14434#0: *71990 [lua] application.lua:385: v= function: 0x402f57a480, client: 127.0.0.1, server: kong_admin, request: "GET /groups HTTP/1.1", host: "localhost:8001"
2022/12/10 16:31:03 [notice] 14434#0: *71990 [lua] application.lua:384: k= on_error, client: 127.0.0.1, server: kong_admin, request: "GET /groups HTTP/1.1", host: "localhost:8001"
2022/12/10 16:31:03 [notice] 14434#0: *71990 [lua] application.lua:385: v= function: 0x402f57a2f8, client: 127.0.0.1, server: kong_admin, request: "GET /groups HTTP/1.1", host: "localhost:8001"
2022/12/10 16:31:03 [notice] 14434#0: *71990 [lua] application.lua:384: k= schema, client: 127.0.0.1, server: kong_admin, request: "GET /groups HTTP/1.1", host: "localhost:8001"
2022/12/10 16:31:03 [notice] 14434#0: *71990 [lua] application.lua:385: v= function: 0x402f57a170, client: 127.0.0.1, server: kong_admin, request: "GET /groups HTTP/1.1", host: "localhost:8001"
@leafo
Copy link
Owner

leafo commented Dec 25, 2022

For future reference: Typically if a route randomly works it's because you declared two routes that match the same URL that share the same precedence. Due to undefined hash-table ordering it may cause which one is selected to swap (this would only happen if code-cache is disabled)

@guy-otonomo
Copy link
Author

Yes, I've closed it, since it is not lapis issue (nor duplicate route definition) but actually changes in latest Kong (see linked issue).
Thanks for writing back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants