proxycfg: unmethod hostnameEndpoints
the method receiver can be replaced by the first argument. This will allow us to extract more from the state struct in the future.
This commit is contained in:
parent
cc816879c0
commit
b57f03feff
|
@ -1460,7 +1460,8 @@ func (s *state) handleUpdateTerminatingGateway(ctx context.Context, u cache.Upda
|
|||
|
||||
if len(resp.Nodes) > 0 {
|
||||
snap.TerminatingGateway.ServiceGroups[sn] = resp.Nodes
|
||||
snap.TerminatingGateway.HostnameServices[sn] = s.hostnameEndpoints(logging.TerminatingGateway, snap.Datacenter, resp.Nodes)
|
||||
snap.TerminatingGateway.HostnameServices[sn] = hostnameEndpoints(
|
||||
s.logger.Named(logging.TerminatingGateway), snap.Datacenter, resp.Nodes)
|
||||
}
|
||||
|
||||
// Store leaf cert for watched service
|
||||
|
@ -1540,7 +1541,8 @@ func (s *state) handleUpdateMeshGateway(ctx context.Context, u cache.UpdateEvent
|
|||
snap.MeshGateway.FedStateGateways = dcIndexedNodes.DatacenterNodes
|
||||
|
||||
for dc, nodes := range dcIndexedNodes.DatacenterNodes {
|
||||
snap.MeshGateway.HostnameDatacenters[dc] = s.hostnameEndpoints(logging.MeshGateway, snap.Datacenter, nodes)
|
||||
snap.MeshGateway.HostnameDatacenters[dc] = hostnameEndpoints(
|
||||
s.logger.Named(logging.MeshGateway), snap.Datacenter, nodes)
|
||||
}
|
||||
|
||||
for dc := range snap.MeshGateway.HostnameDatacenters {
|
||||
|
@ -1709,7 +1711,8 @@ func (s *state) handleUpdateMeshGateway(ctx context.Context, u cache.UpdateEvent
|
|||
|
||||
if len(resp.Nodes) > 0 {
|
||||
snap.MeshGateway.GatewayGroups[dc] = resp.Nodes
|
||||
snap.MeshGateway.HostnameDatacenters[dc] = s.hostnameEndpoints(logging.MeshGateway, snap.Datacenter, resp.Nodes)
|
||||
snap.MeshGateway.HostnameDatacenters[dc] = hostnameEndpoints(
|
||||
s.logger.Named(logging.MeshGateway), snap.Datacenter, resp.Nodes)
|
||||
}
|
||||
default:
|
||||
// do nothing for now
|
||||
|
@ -1960,7 +1963,7 @@ func (s *state) Changed(ns *structs.NodeService, token string) bool {
|
|||
// Envoy cannot resolve hostnames provided through EDS, so we exclusively use CDS for these clusters.
|
||||
// If there is a mix of hostnames and addresses we exclusively use the hostnames, since clusters cannot discover
|
||||
// services with both EDS and DNS.
|
||||
func (s *state) hostnameEndpoints(loggerName string, localDC string, nodes structs.CheckServiceNodes) structs.CheckServiceNodes {
|
||||
func hostnameEndpoints(logger hclog.Logger, localDC string, nodes structs.CheckServiceNodes) structs.CheckServiceNodes {
|
||||
var (
|
||||
hasIP bool
|
||||
hasHostname bool
|
||||
|
@ -1981,9 +1984,8 @@ func (s *state) hostnameEndpoints(loggerName string, localDC string, nodes struc
|
|||
dc := nodes[0].Node.Datacenter
|
||||
sn := nodes[0].Service.CompoundServiceName()
|
||||
|
||||
s.logger.Named(loggerName).
|
||||
Warn("service contains instances with mix of hostnames and IP addresses; only hostnames will be passed to Envoy",
|
||||
"dc", dc, "service", sn.String())
|
||||
logger.Warn("service contains instances with mix of hostnames and IP addresses; only hostnames will be passed to Envoy",
|
||||
"dc", dc, "service", sn.String())
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue