-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: disallow creating duplicate plugins in global rules #12800
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
fix: disallow creating duplicate plugins in global rules #12800
Conversation
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
4df44ed
apisix/plugin.lua
Outdated
|
|
||
| -- remove duplicate plugins | ||
| for plugin_name, _ in pairs(duplicate_plugins) do | ||
| all_plugins[plugin_name] = nil |
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 should warn which plugins are not working.
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.
you are right, thanks. I pushed a new commit that contains:
core.log.warn("found ", plugin_name, " configured across different global rules ",
" it won't get executed")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 think duplicate_plugins are redundant.
Can we merge three loops into one?
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.
done
0e6c6ce
|
lots of CI failed |
apisix/plugin.lua
Outdated
| if global_rule.value and global_rule.value.plugins then | ||
| for plugin_name, plugin_conf in pairs(global_rule.value.plugins) do | ||
| if seen_plugin[plugin_name] then | ||
| core.log.warn("Found ", 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.
we should use error log level
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.
it is an important error message
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.
if we used one plugin about 3 or 5 times
we should throw an error in this case
current way seems wrong
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
Description
When the same plugin is configured across different global rules, there will be no guarantee on which plugin config will be executed first. Additionally, the current architecture does not guarantee plugin execution order according to the priority.
We address this problem by disallowing configuring same plugin across multiple global_rules and sorting the plugins to their priority and executing in order.
Fixes: #12704
Checklist