-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
feat(conf) add plugins
config option to kong.conf
#3387
Conversation
hbagdi
commented
Apr 10, 2018
•
edited
Loading
edited
kong.conf.default
Outdated
@@ -59,6 +59,12 @@ | |||
# adjusted by the `log_level` | |||
# directive. | |||
|
|||
#default_plugins = acl, aws-lambda, basic-auth, bot-detection, correlation-id, cors, datadog, file-log, hmac-auth, http-log, ip-restriction, jwt, key-auth, ldap-auth, loggly, oauth2, rate-limiting, request-size-limiting, request-termination, response-ratelimiting, request-transformer, response-transformer, runscope, statsd, syslog, tcp-log, udp-log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to find a way to respect the 80 chars limit applied everywhere in this file - have you tried to, and if so, what seems to be needed to allow for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not try to find a solution before for this.
However, the following patch seems to be working fine:
diff --git a/kong.conf.default b/kong.conf.default
index 48658cb6..3a6dcf79 100644
--- a/kong.conf.default
+++ b/kong.conf.default
@@ -59,7 +59,13 @@
# adjusted by the `log_level`
# directive.
-#default_plugins = acl, aws-lambda, basic-auth, bot-detection, correlation-id, cors, datadog, file-log, hmac-auth, http-log, ip-restriction, jwt, key-auth, ldap-auth, loggly, oauth2, rate-limiting, request-size-limiting, request-termination, response-ratelimiting, request-transformer, response-transformer, runscope, statsd, syslog, tcp-log, udp-log
+default_plugins = acl, aws-lambda, basic-auth, bot-detection, \
+ correlation-id, cors, datadog, file-log, hmac-auth, \
+ http-log, ip-restriction, jwt, key-auth, ldap-auth, \
+ loggly, oauth2, rate-limiting, request-size-limiting, \
+ request-termination, response-ratelimiting, \
+ request-transformer, response-transformer, \
+ runscope, statsd, syslog, tcp-log, udp-log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: add test for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that this has to be opened against |
21500f5
to
7fa49ec
Compare
7fa49ec
to
9104a28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, except for the added logging - left a comment, please object if I missed something about this logging statement, otherwise once removed, I will slightly extend the description in kong.conf.default
and proceed with the merge!
kong/conf_loader.lua
Outdated
for i = 1, #conf.custom_plugins do | ||
local plugin_name = pl_stringx.strip(conf.custom_plugins[i]) | ||
custom_plugins[plugin_name] = true | ||
plugin_list[plugin_name] = true | ||
log.verbose("custom plugins from conf file: %s", plugin_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging those seems superfluous. When using kong start --vv
, the CLI will print both of these configuration values already, past the merging between config and environment variables (here we also hard-code those have been found in the config file, which might not be true). This would also be very verbose tbh. Logging within loops should rather be done with the debug
level only (but, as said before, such logging statements are already in place).
Additionally, when starting with log_level = debug
, Kong will also print (from the nginx logs) all of the enabled plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you on this, I've dropped the log statements in the updated commit.
Mhhhh why so? It seems to me like this change would be backwards-compatible? Option A would have been breaking, but B, chosen here, isn't, as far as I can tell. |
9104a28
to
d25b86b
Compare
I've removed the logging statements. One thing that I noticed but haven't updated for the sake of simplicity is the following error line returned when a user tries to configure a plugin which is not present in
The default_plugins would work even if they are added to the custom_plugins since all plugins are the same to Kong. I digress, let's . |
@thibaultcha ping |
One thought I had: if the user chooses to disable all plugins, can they do so? It doesn't seem like it to me, since a default value is given to |
@thibaultcha I see your point. If we make plugins configurable then we sure should provide a way to disable all plugins and implicitly a user would assume an empty This could be achieved with a placeholder value and then parse it like we do with other options. |
db417fa
to
85da1dc
Compare
plugins
config option to kong.conf
5775a7d
to
4a5773e
Compare
@@ -25,3 +25,4 @@ nginx_optimizations = off | |||
|
|||
prefix = servroot | |||
log_level = debug | |||
lua_package_path=./spec/fixtures/custom_plugins/?.lua |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was done to fix a failing test case in spec/02-integration/02-cmd/02-start_stop_spec.lua:157
.
4a5773e
to
9677556
Compare
9677556
to
f8486c7
Compare
This PR deprecates a |
b51c33a
to
4db99e9
Compare
"in kong.conf, which will be removed in a future release. " .. | ||
"Please use 'plugins' option to specify your " .. | ||
"custom plugins.", stderr, nil, true) | ||
end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test needs to go in the CLI suite, instead of this Admin API test suite
Problem: All plugins bundled with Kong are loaded by default. There exists no mechanism to disable any of the bundled plugins. Solution: Introduce a config option which controls which of the bundled plugins are loaded into Kong. Implementation: Introduce `plugins` config option and deprecate `custom_plugins` option. Kong will load only plugins which are specified in `plugins` config options. This also is inline in the goal of simplifying Kong's configurations. Plugins specified in `plugins` and `custom_plugins` are merged together to avoid a break change but `custom_plugins` will be removed in future. The new `plugins` options can take in a sugar value `bundled` which loads all the plugins bundled with Kong. This accomplishes good usability and flexibility.
ecabe45
to
0bff011
Compare
end) | ||
end) | ||
|
||
describe("with 'plugins=off, key-auth'", function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should support this case. off
should not be combinable with other plugin names. If you want to only have key-auth
, the correct way of doing so should be plugins=key-auth
.
I suggest treating off
+ anything else as an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was done to keep it consistent with parse_listeners
which have the same behavior.
Could this be covered in a future commit which changes the behavior for all settings or changing this should be in the scope of this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far, this looks good to me now. However it will need manual merging for a bunch of minor stuff. Good job @hbagdi! |
Also, giving it some time if any further reviews come in, or a chance for me to revisit in a day or two. |
LGTM, but I suggest renaming The notion that Kong holds an internal |
@hishamhm Well, we actually chose Overall, |
Problem ------- All plugins bundled with Kong are loaded by default. There exists no mechanism to disable any of the bundled plugins, which can yield considerable performance improvements in the runloop in specific workloads. Solution -------- Introduce a config option which controls which of the bundled plugins are loaded into Kong. Implementation -------------- Introduce `plugins` config option and deprecate `custom_plugins` option. Kong will load only plugins which are specified in `plugins` config options. This also is inline in the goal of simplifying Kong's configurations. Plugins specified in `plugins` and `custom_plugins` are merged together to avoid a break change but `custom_plugins` will be removed in future. The new `plugins` options can take in a sugar value `bundled` which loads all the plugins bundled with Kong. This accomplishes good usability and flexibility. From #3387
Problem ------- All plugins bundled with Kong are loaded by default. There exists no mechanism to disable any of the bundled plugins, which can yield considerable performance improvements in the runloop in specific workloads. Solution -------- Introduce a config option which controls which of the bundled plugins are loaded into Kong. Implementation -------------- Introduce `plugins` config option and deprecate `custom_plugins` option. Kong will load only plugins which are specified in `plugins` config options. This also is inline in the goal of simplifying Kong's configurations. Plugins specified in `plugins` and `custom_plugins` are merged together to avoid a break change but `custom_plugins` will be removed in future. The new `plugins` options can take in a sugar value `bundled` which loads all the plugins bundled with Kong. This accomplishes good usability and flexibility. From #3387
Now merged to next, thank you @hbagdi ! |