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

Impossible to access kong.Router.GetService() from Log phase. #118

Open
arubia opened this issue Jul 1, 2022 · 6 comments
Open

Impossible to access kong.Router.GetService() from Log phase. #118

arubia opened this issue Jul 1, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@arubia
Copy link

arubia commented Jul 1, 2022

kong 2.8.0
go-pdk v0.7.1

For the moment only it is possible to get kong.Router.GetService() information from Access phase and not from the Log phase.
Is a possible bug of kong, because the documentation explains that is possible to get this information from the Log phase:
https://docs.konghq.com/gateway/latest/pdk/kong.router/#kongrouterget_service

Any idea if this is a bug?

@edjanmichiles-toast
Copy link

I'm facing the exactly same problem when trying to access lots of methods from kong.Request in the log phase. I keep getting the error api disabled in the current context even though the data should be accessible according to Kong and NGINX docs

@ImFlog
Copy link

ImFlog commented Feb 7, 2024

Passing by to comment that it is still the case. For instance it fails for kong.Request on :

  • GetPath
  • GetMethod
  • GetQuery
  • ...

For some reason I tried to port a lua version to a Go version and everything that worked on the log phase about the request failed. The Response access seems to work as expected though.

Quick investigations about this error message lead me here : https://github.com/Kong/kong/blob/master/build/openresty/patches/ngx_lua-0.10.26_01-dyn_upstream_keepalive.patch#L1031-L1034 so I guess it's because the lua context is not matching the Go context (or something like this) ?

@gszr
Copy link
Member

gszr commented Feb 22, 2024

This is a known limitation; Kong communicates with the plugin server through a Unix domain socket. The socket API we use for that is not available in the context where we run the Go plugin log handler (it is actually in the context of a timer). I will tag this one as an enhancement request for now. Thank you for the discussion over here!

@gszr gszr added the enhancement New feature or request label Feb 22, 2024
@edjanmichiles-toast
Copy link

edjanmichiles-toast commented Feb 22, 2024

@gszr it would be great to add a disclaimer in the docs for this to let people know of this limitation. Specially because it's not only the .GetService() that doesn't work

@gszr
Copy link
Member

gszr commented Feb 22, 2024

@edjanmichiles-toast Good call - we will work on that.

@garciasdos
Copy link

garciasdos commented Oct 4, 2024

Hey, I'm facing the same issue here using the latest go-pdk version (0.11.0). Is there any news on this topic? Also, no document update was made as far as I can tell, right?

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

No branches or pull requests

5 participants