mirror of https://github.com/status-im/consul.git
Prevent synthetic upstreams without addresses from failing duplicate ip/port validation
This commit is contained in:
parent
d4c401b350
commit
458eb41be1
|
@ -1189,7 +1189,9 @@ func (s *NodeService) Validate() error {
|
|||
}
|
||||
addr = net.JoinHostPort(addr, fmt.Sprintf("%d", u.LocalBindPort))
|
||||
|
||||
if _, ok := bindAddrs[addr]; ok {
|
||||
// Centrally configured upstreams will fail this check if there are multiple because they do not have an address/port.
|
||||
// Only consider non-centrally configured upstreams in this check since those are the ones we create listeners for.
|
||||
if _, ok := bindAddrs[addr]; ok && !u.CentrallyConfigured {
|
||||
result = multierror.Append(result, fmt.Errorf(
|
||||
"upstreams cannot contain duplicates by local bind address and port; %q is specified twice", addr))
|
||||
continue
|
||||
|
|
|
@ -768,6 +768,24 @@ func TestStructs_NodeService_ValidateConnectProxy(t *testing.T) {
|
|||
},
|
||||
"upstreams cannot contain duplicates",
|
||||
},
|
||||
{
|
||||
"connect-proxy: Centrally configured upstreams can have duplicate ip/port",
|
||||
func(x *NodeService) {
|
||||
x.Proxy.Upstreams = Upstreams{
|
||||
{
|
||||
DestinationType: UpstreamDestTypeService,
|
||||
DestinationName: "foo",
|
||||
CentrallyConfigured: true,
|
||||
},
|
||||
{
|
||||
DestinationType: UpstreamDestTypeService,
|
||||
DestinationName: "bar",
|
||||
CentrallyConfigured: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"connect-proxy: Upstreams duplicated by ip and port",
|
||||
func(x *NodeService) {
|
||||
|
|
Loading…
Reference in New Issue