Skip to content

[1.14.x] grpc: ensure grpc resolver correctly uses lan/wan addresses on servers#17286

Merged
rboyer merged 7 commits intorelease/1.14.xfrom
1-14-grpc-resolver-bug
May 11, 2023
Merged

[1.14.x] grpc: ensure grpc resolver correctly uses lan/wan addresses on servers#17286
rboyer merged 7 commits intorelease/1.14.xfrom
1-14-grpc-resolver-bug

Conversation

@rboyer
Copy link
Member

@rboyer rboyer commented May 9, 2023

manual backport of #17270 to 1.14.x

@rboyer rboyer self-assigned this May 9, 2023
rboyer added 2 commits May 10, 2023 10:34
…on servers

The grpc resolver implementation is fed from changes to the
router.Router. Within the router there is a map of various areas storing
the addressing information for servers in those areas. All map entries
are of the WAN variety except a single special entry for the LAN.

Addressing information in the LAN "area" are local addresses intended
for use when making a client-to-server or server-to-server request.

The client agent correctly updates this LAN area when receiving lan serf
events, so by extension the grpc resolver works fine in that scenario.

The server agent only initially populates a single entry in the LAN area
(for itself) on startup, and then never mutates that area map again.
For normal RPCs a different structure is used for LAN routing.

Additionally when selecting a server to contact in the local datacenter
it will randomly select addresses from either the LAN or WAN addressed
entries in the map.

Unfortunately this means that the grpc resolver stack as it exists on
server agents is either broken or only accidentally functions by having
servers dial each other over the WAN-accessible address. If the operator
disables the serf wan port completely likely this incidental functioning
would break.

This PR enforces that local requests for servers (both for stale reads
or leader forwarded requests) exclusively use the LAN "area" information
and also fixes it so that servers keep that area up to date in the
router.

A test for the grpc resolver logic was added, as well as a higher level
full-stack test to ensure the externally perceived bug does not return.
@rboyer rboyer force-pushed the 1-14-grpc-resolver-bug branch from 6ff3936 to 86755d0 Compare May 10, 2023 15:35
@rboyer rboyer force-pushed the 1-14-grpc-resolver-bug branch from 1fd752d to e05ae9a Compare May 10, 2023 16:00
@rboyer rboyer requested review from boxofrad and kisunji May 10, 2023 16:57
@rboyer rboyer marked this pull request as ready for review May 10, 2023 16:57
@rboyer rboyer merged commit 9e7b52d into release/1.14.x May 11, 2023
@rboyer rboyer deleted the 1-14-grpc-resolver-bug branch May 11, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants