open-consul/agent/grpc-internal
R.B. Boyer 0b79707beb
grpc: ensure grpc resolver correctly uses lan/wan addresses on servers (#17270)
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.
2023-05-11 11:08:57 -05:00
..
balancer copyright headers for agent folder (#16704) 2023-03-28 14:39:22 -04:00
resolver grpc: ensure grpc resolver correctly uses lan/wan addresses on servers (#17270) 2023-05-11 11:08:57 -05:00
services/subscribe copyright headers for agent folder (#16704) 2023-03-28 14:39:22 -04:00
client.go copyright headers for agent folder (#16704) 2023-03-28 14:39:22 -04:00
client_test.go grpc: ensure grpc resolver correctly uses lan/wan addresses on servers (#17270) 2023-05-11 11:08:57 -05:00
handler.go Raft storage backend (#16619) 2023-04-04 17:30:06 +01:00
handler_test.go grpc: ensure grpc resolver correctly uses lan/wan addresses on servers (#17270) 2023-05-11 11:08:57 -05:00
listener.go [COMPLIANCE] Add Copyright and License Headers (#16854) 2023-04-20 12:40:22 +00:00
pipe.go server: wire up in-process Resource Service (#16978) 2023-04-18 10:03:23 +01:00
pipe_test.go server: wire up in-process Resource Service (#16978) 2023-04-18 10:03:23 +01:00
server_test.go copyright headers for agent folder (#16704) 2023-03-28 14:39:22 -04:00
stats_test.go copyright headers for agent folder (#16704) 2023-03-28 14:39:22 -04:00
tracker.go copyright headers for agent folder (#16704) 2023-03-28 14:39:22 -04:00