Repository navigation
fix(graphql): skip zero-weight nodes during introspection - #14124
Open
lordcheng10 wants to merge 5 commits into
Open
lordcheng10 wants to merge 5 commits into
lordcheng10 wants to merge 5 commits into
Conversation
Contributor
Author
|
PTAL, thanks! @AlinsRan @nic-6443 @Baoyuantop |
…ection-skip-zero-weight
…ection-skip-zero-weight
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
graphql-limit-countderives an automatic schema introspection endpoint by sorting the configured upstream nodes and choosing the first address. The selector included nodes whose configured weight is zero, even though those nodes are disabled for normal upstream traffic.With a zero-weight node that sorts before an enabled node, schema introspection could be sent to the disabled node and fail while the usable upstream remained available.
This change filters both supported node representations before sorting:
node.weight > 0;If every node is disabled, the existing no-node error path is used.
Reproduction
Against master commit
ae87b942337a7e6897eb153c4f7cfb6ac1ecf3c8, call the shippedfirst_nodeselector with:{ ["127.0.0.1:1000"] = 0, ["127.0.0.1:2000"] = 1, }Before this change it returns
127.0.0.1:1000. After this change it returns127.0.0.1:2000. The same behavior is covered for array-form nodes, and an all-zero set returns no candidate.Test evidence
TEST 68tot/plugin/graphql-limit-count2.t, covering map-form nodes, array-form nodes and an all-disabled upstream.git diff --checkpasses.Test::Nginx::Socket::Lua::Streaminstalled. Repository CI will run the full test environment.make lintcould not start locally because the host lackswgetand the Makefile's OpenResty version probe invokes the system Bash with an unsupported-Voption.Which issue(s) this PR fixes:
Fixes #14123
Checklist