@ -1824,13 +1824,15 @@ func configureClusterWithHostnames(
cluster . DnsRefreshRate = durationpb . New ( rate )
cluster . DnsLookupFamily = envoy_cluster_v3 . Cluster_V4_ONLY
envoyMaxEndpoints := 1
discoveryType := envoy_cluster_v3 . Cluster_Type { Type : envoy_cluster_v3 . Cluster_LOGICAL_DNS }
if dnsDiscoveryType == "strict_dns" {
discoveryType . Type = envoy_cluster_v3 . Cluster_STRICT_DNS
envoyMaxEndpoints = len ( hostnameEndpoints )
}
cluster . ClusterDiscoveryType = & discoveryType
endpoints := make ( [ ] * envoy_endpoint_v3 . LbEndpoint , 0 , 1 )
endpoints := make ( [ ] * envoy_endpoint_v3 . LbEndpoint , 0 , envoyMaxEndpoints )
uniqueHostnames := make ( map [ string ] bool )
var (
@ -1848,14 +1850,17 @@ func configureClusterWithHostnames(
continue
}
if len ( endpoints ) == 0 {
if len ( endpoints ) < envoyMaxEndpoints {
endpoints = append ( endpoints , makeLbEndpoint ( addr , port , health , weight ) )
hostname = addr
idx = i
if len ( endpoints ) == envoyMaxEndpoints {
break
}
}
}
dc := hostnameEndpoints [ idx ] . Node . Datacenter
service := hostnameEndpoints [ idx ] . Service . CompoundServiceName ( )
@ -1867,7 +1872,7 @@ func configureClusterWithHostnames(
endpoints = append ( endpoints , fallback )
}
if len ( uniqueHostnames ) > 1 {
if len ( uniqueHostnames ) > 1 && envoyMaxEndpoints == 1 {
logger . Warn ( fmt . Sprintf ( "service contains instances with more than one unique hostname; only %q be resolved by Envoy" , hostname ) ,
"dc" , dc , "service" , service . String ( ) )
}