fix(resource): support all plugin-bearing resource types in fetch_latest_conf#13663
Open
AlinsRan wants to merge 1 commit into
Open
fix(resource): support all plugin-bearing resource types in fetch_latest_conf#13663AlinsRan wants to merge 1 commit into
AlinsRan wants to merge 1 commit into
Conversation
…est_conf fetch_latest_conf only whitelisted upstreams/routes/services/stream_routes, so any resource that attaches plugins via _meta.parent but wasn't listed (plugin_configs, global_rules, consumers, consumer_groups) hit "unsupported resource type" and returned nil. In particular ai-proxy-multi with multiple instances referenced through a plugin_config_id failed with "failed to fetch the parent config" (5xx). Replace the if/else chain with a whitelist lookup table covering every resource type that can carry plugins; each type maps to its own "/<type>" top-level config key. Add a regression test in ai-proxy-multi.balancer.t: an ai-proxy-multi plugin_config with two instances, referenced by a route via plugin_config_id, now returns a successful response instead of 5xx.
5 tasks
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
Follow-up to #13458 (and issue #13456).
resource.fetch_latest_confonly whitelistedupstreams/routes/services/stream_routes. Any resource that attaches plugins via_meta.parent(set byplugin.set_plugins_meta_parent) but isn't in that list —plugin_configs,global_rules,consumers,consumer_groups— hitunsupported resource typeand returnednil.Concretely,
ai-proxy-multiwith multiple instances referenced through aplugin_config_idcallsfetch_latest_conf(conf._meta.parent.resource_key)inpick_target, getsnil, and the request fails withfailed to fetch the parent config(5xx). The same 5xx happens for ai-proxy-multi carried by a global_rule / consumer / consumer_group.#13458 fixed only
plugin_configsby adding one more branch. As @nic-6443 pointed out there, every supported prefix just maps to itself, so this replaces the if/else chain with a whitelist lookup table covering all plugin-bearing resource types; each maps to its/<type>top-level config key.Fixes
Supersedes #13458, closes #13456.
Test
Added a regression test in
t/plugin/ai-proxy-multi.balancer.t: anai-proxy-multiplugin_config with two instances, referenced by a route viaplugin_config_id. Without the fix the request returns 5xx (failed to fetch the parent config); with it, it proxies successfully. Verified locally — the whole file passes, and revertingresource.luamakes only the new test fail.