mirror of
https://github.com/status-im/consul.git
synced 2025-02-16 15:47:21 +00:00
Account for partitions in xds gen for mesh gw
This commit avoids skipping gateways in remote partitions of the local DC when generating listeners/clusters/endpoints.
This commit is contained in:
parent
935112a47a
commit
a33b6923e0
@ -71,6 +71,10 @@ func (k GatewayKey) IsEmpty() bool {
|
||||
return k.Partition == "" && k.Datacenter == ""
|
||||
}
|
||||
|
||||
func (k GatewayKey) Matches(dc, partition string) bool {
|
||||
return k.Partition == partition && k.Datacenter == dc
|
||||
}
|
||||
|
||||
func gatewayKeyFromString(s string) GatewayKey {
|
||||
split := strings.SplitN(s, ".", 2)
|
||||
|
||||
|
@ -209,7 +209,7 @@ func (s *ResourceGenerator) clustersFromSnapshotMeshGateway(cfgSnap *proxycfg.Co
|
||||
|
||||
// generate the remote dc clusters
|
||||
for _, key := range keys {
|
||||
if key.Datacenter == cfgSnap.Datacenter {
|
||||
if key.Matches(cfgSnap.Datacenter, cfgSnap.ProxyID.PartitionOrEmpty()) {
|
||||
continue // skip local
|
||||
}
|
||||
|
||||
|
@ -114,9 +114,11 @@ func (s *ResourceGenerator) endpointsFromSnapshotMeshGateway(cfgSnap *proxycfg.C
|
||||
|
||||
// generate the endpoints for the gateways in the remote datacenters
|
||||
for _, key := range keys {
|
||||
// Skip creating endpoints for mesh gateways in local DC and gateways in remote DCs with a hostname as their address
|
||||
// EDS cannot resolve hostnames so we provide them through CDS instead
|
||||
if key.Datacenter == cfgSnap.Datacenter || len(cfgSnap.MeshGateway.HostnameDatacenters[key.String()]) > 0 {
|
||||
// Skip creating endpoints for mesh gateways in local DC/partition and gateways.
|
||||
// Also skip gateways with a hostname as their address.
|
||||
// EDS cannot resolve hostnames, so we provide them through CDS instead.
|
||||
if key.Matches(cfgSnap.Datacenter, cfgSnap.ProxyID.PartitionOrEmpty()) ||
|
||||
len(cfgSnap.MeshGateway.HostnameDatacenters[key.String()]) > 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -1139,9 +1139,10 @@ func (s *ResourceGenerator) makeMeshGatewayListener(name, addr string, port int,
|
||||
// We need 1 Filter Chain per datacenter
|
||||
keys := cfgSnap.MeshGateway.Keys()
|
||||
for _, key := range keys {
|
||||
if key.Datacenter == cfgSnap.Datacenter {
|
||||
if key.Matches(cfgSnap.Datacenter, cfgSnap.ProxyID.PartitionOrEmpty()) {
|
||||
continue // skip local
|
||||
}
|
||||
|
||||
clusterName := connect.GatewaySNI(key.Datacenter, key.Partition, cfgSnap.Roots.TrustDomain)
|
||||
filterName := fmt.Sprintf("%s.%s", name, key.String())
|
||||
dcTCPProxy, err := makeTCPProxyFilter(filterName, clusterName, "mesh_gateway_remote.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user