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
7fba7456ec
commit
8eaca35df1
|
@ -1891,6 +1891,7 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||
Nodes: structs.CheckServiceNodes{
|
||||
{
|
||||
Node: &structs.Node{
|
||||
Datacenter: "dc1",
|
||||
Node: "node1",
|
||||
Address: "10.0.0.1",
|
||||
},
|
||||
|
@ -1916,6 +1917,7 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Node: &structs.Node{
|
||||
Datacenter: "dc1",
|
||||
Node: "node2",
|
||||
Address: "10.0.0.2",
|
||||
RaftIndex: structs.RaftIndex{
|
||||
|
@ -1948,6 +1950,7 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||
structs.CheckServiceNodes{
|
||||
{
|
||||
Node: &structs.Node{
|
||||
Datacenter: "dc1",
|
||||
Node: "node1",
|
||||
Address: "10.0.0.1",
|
||||
},
|
||||
|
@ -1973,6 +1976,7 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Node: &structs.Node{
|
||||
Datacenter: "dc1",
|
||||
Node: "node2",
|
||||
Address: "10.0.0.2",
|
||||
RaftIndex: structs.RaftIndex{
|
||||
|
@ -2065,6 +2069,7 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||
Nodes: structs.CheckServiceNodes{
|
||||
{
|
||||
Node: &structs.Node{
|
||||
Datacenter: "dc1",
|
||||
Node: "node2",
|
||||
Address: "10.0.0.2",
|
||||
RaftIndex: structs.RaftIndex{
|
||||
|
@ -2099,6 +2104,7 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||
structs.CheckServiceNodes{
|
||||
{
|
||||
Node: &structs.Node{
|
||||
Datacenter: "dc1",
|
||||
Node: "node2",
|
||||
Address: "10.0.0.2",
|
||||
RaftIndex: structs.RaftIndex{
|
||||
|
@ -2144,6 +2150,7 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||
Nodes: structs.CheckServiceNodes{
|
||||
{
|
||||
Node: &structs.Node{
|
||||
Datacenter: "dc1",
|
||||
Node: "node2",
|
||||
},
|
||||
Service: &structs.NodeService{
|
||||
|
@ -2178,6 +2185,7 @@ func TestState_WatchesAndUpdates(t *testing.T) {
|
|||
structs.CheckServiceNodes{
|
||||
{
|
||||
Node: &structs.Node{
|
||||
Datacenter: "dc1",
|
||||
Node: "node2",
|
||||
},
|
||||
Service: &structs.NodeService{
|
||||
|
|
|
@ -111,9 +111,8 @@ func (s *handlerUpstreams) handleUpdateUpstreams(ctx context.Context, u cache.Up
|
|||
continue
|
||||
}
|
||||
|
||||
// Make sure to use an external address when crossing partitions.
|
||||
// Datacenter is not considered because transparent proxies cannot dial other datacenters.
|
||||
isRemote := !structs.EqualPartitions(node.Node.PartitionOrDefault(), s.proxyID.PartitionOrDefault())
|
||||
// Make sure to use an external address when crossing partition or DC boundaries.
|
||||
isRemote := !snap.Locality.Matches(node.Node.Datacenter, node.Node.PartitionOrDefault())
|
||||
csnIdx, addr, _ := node.BestAddress(isRemote)
|
||||
|
||||
existing := upstreamsSnapshot.PassthroughIndices[addr]
|
||||
|
|
Loading…
Reference in New Issue