Error "plugin is in use but not enabled" in kong environment - lua

We are trying to use the hello-world plugin described in this page - https://streamdata.io/blog/developing-an-helloworld-kong-plugin/
also we have tried this as well - https://github.com/brndmg/kong-plugin-hello-world
We are facing this error in logs:
2017/09/19 09:47:15 [error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong.lua:154: hello-world plugin is in use but not enabled
stack traceback:
[C]: in function 'assert'
/usr/local/share/lua/5.1/kong.lua:154: in function 'init'
init_by_lua:3: in main chunk
The Kong version we are using is 0.11.0.
Can someone suggest what could we be missing?

Kong raises this error because you are asking it to run a plugin called hello-world, without providing the code for this plugin.
This error is trying to say that this plugin is configured to be running on an API/Consumer in the datastore (PostgreSQL or Cassandra), but not added to the Kong configuration custom_plugins settings.
To load a custom plugin, you need two things:
The plugin must be installed in the LUA_PATH (refer to the docs here)
The plugin name must be added to the custom_plugins setting for Kong to load it (from the LUA_PATH)
You can edit your configuration file to make Kong load the plugin:
custom_plugins = hello-world
or specify it via an environment variable:
export KONG_CUSTOM_PLUGINS=hello-world
If you are still seeing this error, it could mean that you are not starting Kong with the configuration file you are editing. Start Kong in verbose mode to see what configuration file it is reading and what is the values of custom_plugins:
$ kong start --vv
You can read more on how to install and custom plugins for 0.11 in the Plugins Development Guide section of the website.

I fixed this issue by adding things in custom_plugins and lua_package_path .
Here are the steps to enable and use custom plugin in kong Env.
1 - Add custom plugin name in --- custom_plugins = hello-world
2 - Install hello-world plugin by using following steps ---
If you have source code of your plugin then move into it and execute the command --- "luarocks make"
it will install your plugin.
now you have to execute a command "make install-dev" make sure your plugin have makefile like as --
Once you execute this command "make install-dev". it will create lua file at a location something like that -
/your-plugin-path/lua_modules/share/lua/5.1/kong/plugins/your-plugin-name/?.lua
just copy this path and add it into the kong configuration file in lua_package_path
Something like that --
lua_package_path=/your-plugin-path/lua_modules/share/lua/5.1/kong/plugins/your-plugin-name/?.lua
Now you done your job.
Just start kong -- kong start --vv
You will see that the plugin loaded into kong plugin env.
#Enjoy

Related

Deploying Cloud Run via YAML gives Revision named 'yourservicename-00001-soj' with different configuration already exists

When using the following command to deploy a new Cloud Run revision,
gcloud run services replace service.yaml
The deployment fails with this error
ERROR: (gcloud.run.services.replace) ALREADY_EXISTS: Revision named 'yourservicename-00001-soj' with different configuration already exists.
This occurs when you have followed Google's documentation which instructs you to pull down the current service YAML description into a file, make edits and then redeploy it.
This is because the documentation is wrong, or Google's service has regressed since it was authored.
Edit the YAML and remove spec.template.metadata.name and try again.

Bazel internal shell issue using windows

I am trying to migrate a huge project having visual studio and maven projects to bazel. I need to access our in house maven server which is encrypted. To get access I need the load the maven_jar skylark extension since the default impl does not support encryption (get error 401). using the extension leads to a lot of troubles, like:
ERROR: BUILD:4:1: no such package '#org_bouncycastle_bcpkix_jdk15on//jar': Traceback (most recent call last):
File ".../external/bazel_tools/tools/build_defs/repo/maven_rules.bzl", line 280
_maven_artifact_impl(ctx, "jar", _maven_jar_build_file_te...)
File ".../external/bazel_tools/tools/build_defs/repo/maven_rules.bzl", line 248, in _maven_artifact_impl
fail(("%s: Failed to create dirs in e...))
org_bouncycastle_bcpkix_jdk15on: Failed to create dirs in execution root.
The main issue seems to be the shell that needs to be provided to bazel in BAZEL_SH environment variables:
I am working under windows
I am using bazel 0.23.2
bazel seems to run a bash command using "bash" directly and not the one provided by env variable.
I got a ubuntu shell installed in windows. bazel was using everything from ubuntu, especially when using maven (settings.xml was using from ubuntu ~/.m2 and not from windows user)
after uninstalling ubuntu and making sure that bash in a cmd ends up in "command not found" I also removed the BAZEL_SH env var and bazel throws the message above
after setting the BAZEL_SH variable again it fails with the same error message
I am assuming that bazel gets a bash from somewhere or is ignoring the env variable. My questions are:
1. How to setup a correct shell?
2. Is BAZEL_SH needed when using current version?
For me the doc at bazel website about setup is outdated.
Cheers
Please consider using rules_jvm_external to manage your Maven dependencies. It supports both Windows and private repositories using HTTP Basic Authentication.
For me the doc at bazel website about setup is outdated.
The Bazel team is aware of this and will be updating our docs shortly.

Custom plugin for Kong v1.0.2 is enabled but not installed

I have a custom plugin for Kong which worked fine for Kong v0.14.1 but after I upgraded to v.1.0.2 it's throwing an error.
OS used: macOS Mojave
In kong.conf file I have this code:
log_level = debug
plugins=my-custom-plugin
I try to start Kong with this command:
kong start -c kong.conf
and I get this error:
Error: /usr/local/share/lua/5.1/kong/cmd/start.lua:50: nginx: [error] init_by_lua
error: /usr/local/share/lua/5.1/kong/init.lua:344: my-custom-plugin plugin is enabled but not installed;
module 'kong.plugins.my-custom-plugin.handler' not found:No LuaRocks module found for kong.plugins.my-custom-plugin.handler
no field package.preload['kong.plugins.my-custom-plugin.handler']
no file './kong/plugins/kong-my-custom-plugin/handler.lua'...
I installed the plugin using this command:
luarocks make
which gave the following output:
my-custom-plugin 1.0-1 is now installed in /usr/local/opt/kong (license: MIT)
Somehow, it appears that Kong is unable to find my installed custom plugin. Any idea why this happens?
#user5377037's answer has most of the relevant details, I just wanted to mention that as of Kong 0.14.x, "custom_plugins" is now just "plugins".
One of the reasons for this change is that you can now use this new variable name to choose to load or not to load plugins that are bundled with Kong -- a useful feature for some. However, if you want to load your custom plugin AND the bundled plugins, you now have to specify the bundled keyword to indicate that you want to keep the bundled plugins loaded.
Pre 0.14.x
The practical effect is that in Kong < 0.14.x:
custom_plugins = plugin1,plugin2
Or
KONG_CUSTOM_PLUGINS=<plugin-name>
Post 0.14.x
In Kong >= 0.14.x, you now write:
plugins = bundled,plugin1,plugin2
Or
KONG_PLUGINS=bundled,<plugin-name>
If You Don't Use bundled
If you don't add the bundled keyword, you'll likely face something like this error:
nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:292: key-auth plugin is in use but not enabled
stack traceback:
[C]: in function 'assert'
/usr/local/share/lua/5.1/kong/init.lua:292: in function 'init'
init_by_lua:3: in main chunk
This means that you've set your proxy to use some plugin, but now you aren't loading that plugin on startup so Kong doesn't know what to do and quits. Essentially, you will only be loading your one single custom plugin which probably isn't what you want.
lua_package_path
The notes about lua_package_path and KONG_LUA_PACKAGE_PATH remain the same as in user5377037's post.
References
Upgrade Documentation
Configuration Reference
Load the plugin
You must now add the custom plugin’s name to the custom_plugins list in your Kong configuration (on each Kong node):
custom_plugins = <plugin-name>
If you are using two or more custom plugins, insert commas in between, like so:
custom_plugins = plugin1,plugin2
Note: You can also set this property via its environment variable equivalent: KONG_CUSTOM_PLUGINS or define custom plugin in configuration property like:
KONG_CUSTOM_PLUGINS=<plugin-name> kong start
Reminder: don’t forget to update the custom_plugins directive for each node in your Kong cluster.
Verify loading the plugin
You should now be able to start Kong without any issue. Consult your custom plugin’s instructions on how to enable/configure your plugin on an API or Consumer object.
To make sure your plugin is being loaded by Kong, you can start Kong with a debug log level:
log_level = debug
OR:
KONG_LOG_LEVEL=debug
Then, you should see the following log for each plugin being loaded:
[debug] Loading plugin <plugin-name>
And here is workaround steps for adding things in custom_plugins and lua_package_path.
Add custom plugin name in : custom_plugins = <plugin-name>
Install hello-world plugin by using following steps :
If you have source code of your plugin then move into it and execute the command : luarocks make it will install your plugin.
Now you have to execute a command : make install-dev make sure your plugin have makefile like as:
Once you execute this command make install-dev. It will create lua file at a location something like that :
/your-plugin-path/**lua_modules/share/lua/5.1/kong/plugins/your-plugin-name/**?.lua
Just copy this path and add it into the kong configuration file in lua_package_path
lua_package_path=/your-plugin-path/lua_modules/share/lua/5.1/kong/plugins/your-plugin-name/?.lua
Just start kong : kong start --vv
It looks like it can't find the handler.lua file, which is required. Can you run $ tree . at the root of your plugin project?
Here's the result of that same command for a test plugin I did a while back (https://github.com/jerneyio/kong-plugin-header-echo)
$ tree .
.
├── README.md
├── kong
│   └── plugins
│   └── kong-plugin-header-echo
│   ├── handler.lua
│   └── schema.lua
├── kong-plugin-header-echo-0.1.0-1.all.rock
└── kong-plugin-header-echo-0.1.0-1.rockspec
Also, are you sure your handler.lua is exposed in your rockspec? Again, successful example here:
$ cat kong-plugin-header-echo-0.1.0-1.rockspec
package = "kong-plugin-header-echo"
version = "0.1.0-1"
source = {
url = "git//github.com/jerneyio/kong-plugin-header-echo.git"
}
description = {
homepage = "https://github.com/jerneyio/kong-plugin-header-echo",
license = "MIT"
}
dependencies = {
"lua >= 5.3",
"kong >= 0.14"
}
build = {
type = "builtin",
modules = {
["kong.plugins.kong-plugin-header-echo.handler"] = "kong/plugins/kong-plugin-header-echo/handler.lua",
["kong.plugins.kong-plugin-header-echo.schema"] = "kong/plugins/kong-plugin-header-echo/schema.lua"
}
}

Using Jenkins' Testlink plugin

Hi i'm trying to implement testlink plugin in jenkins.
I followed this tutorial http://tupilabs.com/books/jenkins-testlink-plugin-tutorial/en/book.pdf
I can build the project but the test isn't run.
there is a file not found error
I don't understand where i have to put my testfile. I supposed the output format must be TestNG, but where i have to put it ?
Thanks for your answer
I had exactly the same problem with building project, when I was following through tutorial placed in book Jenkins:The Definitive Guide.
I had Jenkis (jenkins-1.502.msi) instaled on Windows7 64 as a service - whatever I tried always received:
[workspace] $ mvn.bat
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: Cannot run program "mvn.bat" (in directory "C:\Work\jenkins\jobs\gameoflifedefault\workspace"): CreateProcess error=2, The system cannot find the file specified
Unfortunately I didn't managed to resolve this jenkis service problem but found another solution to make it work on Windows:
Use Apache Tomcat java server - if you have properly configured Tomcat do:
Download jenkins.war
Place it in webapps folder in your Tomcat directory
Run Tomcat and check via http://localhost:8080/manager if jenkins is there
Go to http://localhost:8080/jenkins
Now mvn.bat is seen and my build run without problems.
Ofcourse I understand that maven is properly configured on your system - so you should had specified in environmental variables:
variable: M2
value: %M2_HOME%\bin
variable: M2_HOME
value: C:\yourPathToMaven\apache-maven-3.0.4
variable: PATH
add to existing value: %M2_HOME%;
To check if maven is visible type in comand promp:
C:\Users\x>mvn --version
You should get something like:
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: C:\Work\Maven\apache-maven-3.0.4
Java version: 1.7.0, vendor: Oracle Corporation
Java home: C:\Work\ja\jdk1.7.0_10\jre
Default locale: en_US, platform encoding: Cp1250
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Hope it helps.
Update : I found that the error was :
Cannot run program mvn.bat in directory d:/jenkins/jobs/JobTest/workspace CreateProcess error=2 File not found.
I made a free style project as said in the tutorial. It seems to be a maven error so i don't understand ...
If somebody can help me i'd be gratefull

RabbitMQ Plugin Dependencies

I'm setting up a special ubuntu vm for rabbitmq plugin development. I am working through the plugin development guide here: http://www.rabbitmq.com/plugin-development.html
The metronome plugin is working, so I wanted to get the rabbitmq_management plugin working as well.
I set up the necessary symlinks and when I run rabbitmq-plugin enable rabbitmq_management, I get the following error in the console:
% ../scripts/rabbitmq-plugins enable rabbitmq_management
Error: The following dependencies could not be found:
mochiweb
webmachine
I don't know where to put these dependencies (mochiweb, webmachine) so the rabbitmq_management (or it's dependencies) can see them.
I have tried to clone from git and make those projects directly in the rabbitmq-server/plugins directory with no luck
Some plugins depend on other plugins. In this case you need the mochiweb and webmachine plugins. Place them inside the broker plugins folder
I had the same problem:
Error: The following plugins could not be found:
RabbitMQ_management
After a long period, of reinstall, remove and reinstall. The solution is simply that the plugin name is case sensitive. Therefore, check the plugin directory for the correct case. Simply changing the command from:
RabbitMQ-plugins enable RabbitMQ_Management
to
RabbitMQ-plugins enable rabbitmq_management
solved my issue.

Resources