Cannot enable session plugin in Kong (even after upgrading to latest)

To start I had Kong 0.14.1 installed (without docker) in ubuntu 16.04 working fine.

I tried adding the ‘Session’ plugin (following the plugin page’s example)

curl -X POST http://localhost:8001/services/1d57a271-1a70-42ac-bb37-2e60405af347/plugins \
 --data "name=session"  \
 --data "config.storage=kong" \
 --data "config.cookie_secure=false"

But it just returned the 400 error:

{"message":"schema violation (name: plugin 'session' not enabled; add it to the 'plugins' configuration property)","name":"schema violation","fields":{"name":"plugin 'session' not enabled; add it to the 'plugins' configuration property"},"code":2}

I realized that session plugin was not included in my current version and so I attempted to upgrade to the latest (1.1.2) with these commands:

sudo dpkg -P kong-community-edition
wget -O kong-community-edition-1.1.2.trusty.all.deb https://bintray.com/kong/kong-community-edition-deb/download_file?file_path=dists/kong-community-edition-1.1.2.trusty.all.deb 
sudo dpkg -i kong-community-edition-1.1.2.*.deb   
sudo kong migrations up
sudo kong migrations finish

followed by a system restart just to be sure.

Now when i run the following i can see I’m on the latest version 1.1.2

 dpkg -l | grep kong

But I still get the same error when trying to enable the package.

I did get the following error when uninstalling kong with ‘sudo dpkg -P kong-community-edition’, but I’m not sure how to handle this warning, or if it is even relevant to my issue.

Removing kong-community-edition (1.1.2) ...
dpkg: warning: while removing kong-community-edition, directory '/usr/local/lib' not empty so not removed
dpkg: warning: while removing kong-community-edition, directory '/usr/local/bin' not empty so not removed
dpkg: warning: while removing kong-community-edition, directory '/usr/local/share' not empty so not removed
dpkg: warning: while removing kong-community-edition, directory '/usr/local/kong' not empty so not removed

What should I correct to allow me to enable the session plugin?

Hello!

It seems that there is an inconsistency in the documentation. The session plugin is said to be bundled with Kong 1.0.x, but that is not the case (nor in 1.1 as of today either). Once it is properly installed locally, you can enable it with:

plugins = bundled, session

See the configuration documentation. You can also specify this property as an environment variable as usual.

I also advise you to have a look at the Install plugin troubleshooting section of the documentation, which documents related errors and their workarounds:

Best,

Thanks, when adding this to my config as you said:

plugins=bundled,session

I get this error on Kong’s startup

nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:402: error loading plugin schemas: on plugin 'session': session plugin is enabled but not installed;

But it sounds like you’re saying the session plugin isn’t properly bundled in yet. So I will have to get the source for the plugin from here: https://github.com/Kong/kong-plugin-session
and figure out how to install the plugin using the documentation here:
https://docs.konghq.com/1.1.x/plugin-development/distribution/?_ga=2.38394979.1991677927.1558543387-1804803425.1516137689#installing-the-plugin

I will try it out,
Thank you

I highly suspected that you would run into this error, which is why I pointed you to the troubleshooting section on installing plugins.

If your problem has been solved, please mark it as such by selecting my above post as a valid answer so it may help future readers of this forum.

Best,

Yes, I now have the plugin running.
These are the steps I took in case anybody else was running into this issue:

  1. Downloaded the session source code with the download button from here: GitHub - Kong/kong-plugin-session: 🍪 Session plugin for Kong - this plugin has been moved into https://github.com/Kong/kong, please open issues and PRs in that repo

  2. Copied and unpacked it to the machine running my Kong instance.

  3. Followed instructions here to install with the source. I tried both the make and the pack and rock approaches. When installing from the rock I got some “/usr/local/share/lua/5.1/kong/plugins/session/*** is not tracked by this installation of LuaRocks.” warnings but didn’t seem to cause a problem.

  4. Updated the conf file ‘/etc/kong/kong.conf’: plugins=bundled,session

  5. Updated the db: sudo kong migrations up

  6. Started up Kong, though it seems now I have to sudo, or else I get the following error.

/usr/local/share/lua/5.1/kong/cmd/start.lua:61: /usr/local/share/lua/5.1/kong/cmd/start.lua:37: nginx configuration is invalid (exit code 1):
nginx: [alert] could not open error log file: open() “/usr/local/kong/logs/error.log” failed (13: Permission denied)
nginx: the configuration file /usr/local/kong/nginx.conf syntax is ok