@@ -1824,13 +1824,15 @@ func configureClusterWithHostnames(
1824
1824
cluster .DnsRefreshRate = durationpb .New (rate )
1825
1825
cluster .DnsLookupFamily = envoy_cluster_v3 .Cluster_V4_ONLY
1826
1826
1827
+ envoyMaxEndpoints := 1
1827
1828
discoveryType := envoy_cluster_v3.Cluster_Type {Type : envoy_cluster_v3 .Cluster_LOGICAL_DNS }
1828
1829
if dnsDiscoveryType == "strict_dns" {
1829
1830
discoveryType .Type = envoy_cluster_v3 .Cluster_STRICT_DNS
1831
+ envoyMaxEndpoints = len (hostnameEndpoints )
1830
1832
}
1831
1833
cluster .ClusterDiscoveryType = & discoveryType
1832
1834
1833
- endpoints := make ([]* envoy_endpoint_v3.LbEndpoint , 0 , 1 )
1835
+ endpoints := make ([]* envoy_endpoint_v3.LbEndpoint , 0 , envoyMaxEndpoints )
1834
1836
uniqueHostnames := make (map [string ]bool )
1835
1837
1836
1838
var (
@@ -1848,12 +1850,15 @@ func configureClusterWithHostnames(
1848
1850
continue
1849
1851
}
1850
1852
1851
- if len (endpoints ) == 0 {
1853
+ if len (endpoints ) < envoyMaxEndpoints {
1852
1854
endpoints = append (endpoints , makeLbEndpoint (addr , port , health , weight ))
1853
1855
1854
1856
hostname = addr
1855
1857
idx = i
1856
- break
1858
+
1859
+ if len (endpoints ) == envoyMaxEndpoints {
1860
+ break
1861
+ }
1857
1862
}
1858
1863
}
1859
1864
@@ -1867,8 +1872,8 @@ func configureClusterWithHostnames(
1867
1872
1868
1873
endpoints = append (endpoints , fallback )
1869
1874
}
1870
- if len (uniqueHostnames ) > 1 {
1871
- logger .Warn (fmt .Sprintf ("service contains instances with more than one unique hostname; only %q be resolved by Envoy" , hostname ),
1875
+ if len (uniqueHostnames ) > 1 && envoyMaxEndpoints == 1 {
1876
+ logger .Warn (fmt .Sprintf ("service contains instances with more than one unique hostname; only %q will be resolved by Envoy" , hostname ),
1872
1877
"dc" , dc , "service" , service .String ())
1873
1878
}
1874
1879
0 commit comments