mirror of
https://github.com/status-im/consul.git
synced 2025-01-18 09:41:32 +00:00
Account for upstream targets in another DC.
Transparent proxies typically cannot dial upstreams in remote datacenters. However, if their upstream configures a redirect to a remote DC then the upstream targets will be in another datacenter. In that sort of case we should use the WAN address for the passthrough.
This commit is contained in:
parent
cbea3d203c
commit
ceb52d649a
@ -1891,8 +1891,9 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||||||
Nodes: structs.CheckServiceNodes{
|
Nodes: structs.CheckServiceNodes{
|
||||||
{
|
{
|
||||||
Node: &structs.Node{
|
Node: &structs.Node{
|
||||||
Node: "node1",
|
Datacenter: "dc1",
|
||||||
Address: "10.0.0.1",
|
Node: "node1",
|
||||||
|
Address: "10.0.0.1",
|
||||||
},
|
},
|
||||||
Service: &structs.NodeService{
|
Service: &structs.NodeService{
|
||||||
Kind: structs.ServiceKindConnectProxy,
|
Kind: structs.ServiceKindConnectProxy,
|
||||||
@ -1916,8 +1917,9 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Node: &structs.Node{
|
Node: &structs.Node{
|
||||||
Node: "node2",
|
Datacenter: "dc1",
|
||||||
Address: "10.0.0.2",
|
Node: "node2",
|
||||||
|
Address: "10.0.0.2",
|
||||||
RaftIndex: structs.RaftIndex{
|
RaftIndex: structs.RaftIndex{
|
||||||
ModifyIndex: 21,
|
ModifyIndex: 21,
|
||||||
},
|
},
|
||||||
@ -1948,8 +1950,9 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||||||
structs.CheckServiceNodes{
|
structs.CheckServiceNodes{
|
||||||
{
|
{
|
||||||
Node: &structs.Node{
|
Node: &structs.Node{
|
||||||
Node: "node1",
|
Datacenter: "dc1",
|
||||||
Address: "10.0.0.1",
|
Node: "node1",
|
||||||
|
Address: "10.0.0.1",
|
||||||
},
|
},
|
||||||
Service: &structs.NodeService{
|
Service: &structs.NodeService{
|
||||||
Kind: structs.ServiceKindConnectProxy,
|
Kind: structs.ServiceKindConnectProxy,
|
||||||
@ -1973,8 +1976,9 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Node: &structs.Node{
|
Node: &structs.Node{
|
||||||
Node: "node2",
|
Datacenter: "dc1",
|
||||||
Address: "10.0.0.2",
|
Node: "node2",
|
||||||
|
Address: "10.0.0.2",
|
||||||
RaftIndex: structs.RaftIndex{
|
RaftIndex: structs.RaftIndex{
|
||||||
ModifyIndex: 21,
|
ModifyIndex: 21,
|
||||||
},
|
},
|
||||||
@ -2065,8 +2069,9 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||||||
Nodes: structs.CheckServiceNodes{
|
Nodes: structs.CheckServiceNodes{
|
||||||
{
|
{
|
||||||
Node: &structs.Node{
|
Node: &structs.Node{
|
||||||
Node: "node2",
|
Datacenter: "dc1",
|
||||||
Address: "10.0.0.2",
|
Node: "node2",
|
||||||
|
Address: "10.0.0.2",
|
||||||
RaftIndex: structs.RaftIndex{
|
RaftIndex: structs.RaftIndex{
|
||||||
ModifyIndex: 21,
|
ModifyIndex: 21,
|
||||||
},
|
},
|
||||||
@ -2099,8 +2104,9 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||||||
structs.CheckServiceNodes{
|
structs.CheckServiceNodes{
|
||||||
{
|
{
|
||||||
Node: &structs.Node{
|
Node: &structs.Node{
|
||||||
Node: "node2",
|
Datacenter: "dc1",
|
||||||
Address: "10.0.0.2",
|
Node: "node2",
|
||||||
|
Address: "10.0.0.2",
|
||||||
RaftIndex: structs.RaftIndex{
|
RaftIndex: structs.RaftIndex{
|
||||||
ModifyIndex: 21,
|
ModifyIndex: 21,
|
||||||
},
|
},
|
||||||
@ -2144,7 +2150,8 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||||||
Nodes: structs.CheckServiceNodes{
|
Nodes: structs.CheckServiceNodes{
|
||||||
{
|
{
|
||||||
Node: &structs.Node{
|
Node: &structs.Node{
|
||||||
Node: "node2",
|
Datacenter: "dc1",
|
||||||
|
Node: "node2",
|
||||||
},
|
},
|
||||||
Service: &structs.NodeService{
|
Service: &structs.NodeService{
|
||||||
Kind: structs.ServiceKindConnectProxy,
|
Kind: structs.ServiceKindConnectProxy,
|
||||||
@ -2178,7 +2185,8 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||||||
structs.CheckServiceNodes{
|
structs.CheckServiceNodes{
|
||||||
{
|
{
|
||||||
Node: &structs.Node{
|
Node: &structs.Node{
|
||||||
Node: "node2",
|
Datacenter: "dc1",
|
||||||
|
Node: "node2",
|
||||||
},
|
},
|
||||||
Service: &structs.NodeService{
|
Service: &structs.NodeService{
|
||||||
Kind: structs.ServiceKindConnectProxy,
|
Kind: structs.ServiceKindConnectProxy,
|
||||||
|
@ -111,9 +111,8 @@ func (s *handlerUpstreams) handleUpdateUpstreams(ctx context.Context, u cache.Up
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure to use an external address when crossing partitions.
|
// Make sure to use an external address when crossing partition or DC boundaries.
|
||||||
// Datacenter is not considered because transparent proxies cannot dial other datacenters.
|
isRemote := !snap.Locality.Matches(node.Node.Datacenter, node.Node.PartitionOrDefault())
|
||||||
isRemote := !structs.EqualPartitions(node.Node.PartitionOrDefault(), s.proxyID.PartitionOrDefault())
|
|
||||||
csnIdx, addr, _ := node.BestAddress(isRemote)
|
csnIdx, addr, _ := node.BestAddress(isRemote)
|
||||||
|
|
||||||
existing := upstreamsSnapshot.PassthroughIndices[addr]
|
existing := upstreamsSnapshot.PassthroughIndices[addr]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user