fix(workflow): skip the action plugin in the chain to avoid double execution#13617
Open
shreemaan-abhishek wants to merge 1 commit into
Open
fix(workflow): skip the action plugin in the chain to avoid double execution#13617shreemaan-abhishek wants to merge 1 commit into
shreemaan-abhishek wants to merge 1 commit into
Conversation
…ecution When a plugin such as limit-count or limit-conn runs as a workflow action and the same plugin is also configured in the normal plugin chain, the plugin runs twice per request (e.g. a request is counted twice against a rate limit). Mark the action plugin as skipped for the rest of the request so it does not run again in the chain. Signed-off-by: shreemaan-abhishek <shreemaan.abhishek@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
workflowPlugin (priority 1006) can run a plugin such aslimit-count(priority 1002) orlimit-conn(priority 1003) as an action. When the same plugin is also configured directly in the normal plugin chain on the same Route/Service/Consumer/Global Rule, the plugin ends up running twice per request:workflowaction handler, andworkflowaccess handler returnsnilon the non-rejected path, so it does not short-circuit the chain).The visible impact is that a request is counted/limited twice. For
limit-countthe quota is consumed at 2x; the same applies tolimit-conn(which is also double-counted in bothaccessandlog). This is reachable with stock plugins and a non-exotic configuration.This PR adds
plugin.skip_plugin(ctx, name)to mark the action plugin as skipped for the rest of the request, so onceworkflowruns it as an action it is not executed again in the normal chain. The skip is honored in bothrun_pluginloops (access/rewrite and log/header_filter/body_filter), solimit-conn'slog-phase decrement is also handled only by theworkflowaction.Which issue(s) this PR fixes:
N/A
Checklist