Kong unable to load api.lua from custom plugin folder

43 views
Skip to first unread message

ssh...@egnyte.com

unread,
May 9, 2017, 3:30:51 PM5/9/17
to Kong
Hi,

I have defined a custom plugin and made sure all the conf is right.

Kong is able to load the handler, schema and doas.lua files from my custom plugin folder, however somehow it is not able to find the api.lua file even though it exists

I added some debug to utils.lua:load_module_if_exists to get the error and I see this

2017/05/09 19:17:08 [debug] 6274#0: *3 [lua] utils.lua:386: load_module_if_exists(): er Api Loading status: falsekong.plugins.eg-rate-limiting.apimodule 'kong.plugins.eg-rate-limiting.api' not found:
        no field package.preload['kong.plugins.eg-rate-limiting.api']
        no file '/home/sshetty/installers/kong/eg-plugins/kong/plugins/eg-rate-limiting/api.lua'
        no file '/home/sshetty/installers/kong/eg-plugins/kong/plugins/eg-rate-limiting/api/init.lua'

However the file /home/sshetty/installers/kong/eg-plugins/kong/plugins/eg-rate-limiting/api.lua does exist

[root@l1:/home/sshetty/installers/kong]# ls -lhrt /home/sshetty/installers/kong/eg-plugins/kong/plugins/eg-rate-limiting/api.lua
-rwxr-xr-x. 1 root root 380 May  9 19:13 /home/sshetty/installers/kong/eg-plugins/kong/plugins/eg-rate-limiting/api.lua
[root@l1:/home/sshetty/installers/kong]#

It only happens with api.lua, handler.lua etc are loaded correctly. LUA_PATH includes /home/sshetty/installers/kong/eg-plugins and that is proven by loading of handler.lua for the plugin. 

Thanks
Sachin

Thibault Charbonnier

unread,
May 9, 2017, 4:06:29 PM5/9/17
to kong...@googlegroups.com
Hi,

It could be that your file is there indeed, but has a Lua syntax error
in it, and that the 'utils.load_module_if_exists' utility reports a
"missing" error because I believe it doesn't - as it stand - know the
reason *why* the module could not be loaded.

Could you check for such a syntax error in your api.lua file, or paste
it online somewhere (gist/pastebin), and send us the link :)

Cheers,
Thibault
> --
> You received this message because you are subscribed to the Google
> Groups "Kong" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to konglayer+...@googlegroups.com
> <mailto:konglayer+...@googlegroups.com>.
> To post to this group, send email to kong...@googlegroups.com
> <mailto:kong...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/konglayer.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/konglayer/901c7da2-9c6a-41fe-95d5-04ba7816e6a6%40googlegroups.com
> <https://groups.google.com/d/msgid/konglayer/901c7da2-9c6a-41fe-95d5-04ba7816e6a6%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Sachin Shetty

unread,
May 10, 2017, 1:37:17 AM5/10/17
to Thibault Charbonnier, kong...@googlegroups.com
Hi,

my api file is a simple file

cat /home/sshetty/installers/kong/eg-plugins/kong/plugins/eg-rate-limiting/api.lua

local crud = require "kong.api.crud_helpers"
local utils = require "kong.tools.utils"

return {
  ["/eg-rate-limiting/rules"] = {
    GET = function(self, dao_factory, helpers)
      crud.paginated_set(self, dao_factory.eg_ratelimiting_rules)
    end,

       POST = function(self, dao_factory, helpers)
      crud.post(self.params, dao_factory.eg_ratelimiting_rules)
    end

  }
}

luac generates the out file without any errors


> To post to this group, send email to kong...@googlegroups.com
--
You received this message because you are subscribed to a topic in the Google Groups "Kong" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/konglayer/mImn5FVPao4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to konglayer+unsubscribe@googlegroups.com.
To post to this group, send email to kong...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages