Closed mathieucarbou closed 3 years ago
@myronkscott @chrisdennis : so after discussions I have updated this PR to account for the bind address when not a wildcard one.
But we also settled on not merging this PR yet. but instead group it with other fixes / discussions about hostname / bind addr
@myronkscott : I have updated the PR to account for your last comment, to consider also the bind address, and I have updated the systems tests. All is working fine:
Case 1)
<hostname>
<hostname>
Result: Redirecting client: /127.0.0.1:58937 to proposed address: C02YJ2F2JGH6.local:46238
(using the proposed address by core)Case 2)
<hostname>
<hostname>
Result: Redirecting client: /127.0.0.1:59121 to node: node-1-1@localhost:42894 through public endpoint
(redirection to public endpoint)Case 3)
<hostname>
<hostname>
Result: Redirecting client: /127.0.0.1:59053 to proposed address: 127.0.0.1:37132
(redirection to the core proposed address, which is the bind address)Case 4) => Case that was missing in the code
<hostname>
<hostname>
Result: Redirecting client: /127.0.0.1:59447 to node: node-1-2@localhost:46384 through public endpoint
(redirection to the public endpoint of the node found thanks to its bind address/port)
Implementation of a
NetworkTranslator
for 10.x that will correctly pick the right endpoint for the active node when a passive sends a redirection back to a client.A terracotta cluster is either meant to be used with the internal endpoints of the nodes, or the public configured endpoints if configured, but not both at the same time.
If public endpoints are not configured, all clients need to use the internal endpoints, and they must be reachable from all clients.
If public endpoints are configured, all clients need to use these public endpoints, not internal ones. All the clients will have to be able to reach the nodes by using these public endpoints.
Technically, it means that if all clients are in the same network as all nodes, public endpoints are not necessary. If clients are in another network and internal endpoints cannot be reached, then public endpoints can be configured to reach them. The user will be responsible to configure NAT / DNS / etc.
If some clients need to be in the same network as nodes (so clients being both outside and inside), then the user will have to make sure that the public endpoints also resolve to the node internal endpoints, even within the same network.
The
NetworkTranslator
was always returning the "internal" endpoint of the active server, which of course is not always accessible from clients outside an isolated "terracotta network", which could prevent them from connecting to the cluster.This fix works this way:
CC @tglaeser