1
0
Fork 0

Ignore server for container with empty IP address.

This commit is contained in:
Ludovic Fernandez 2018-04-22 09:10:03 +02:00 committed by Traefiker Bot
parent 5924a40222
commit 7ef8d6fa10
4 changed files with 145 additions and 2 deletions

View file

@ -166,6 +166,11 @@ func getServers(service rancherData) map[string]types.Server {
var servers map[string]types.Server
for index, ip := range service.Containers {
if len(ip) == 0 {
log.Warnf("Unable to find the IP address for a container in the service %q: this container is ignored.", service.Name)
continue
}
if servers == nil {
servers = make(map[string]types.Server)
}

View file

@ -832,6 +832,18 @@ func TestGetServers(t *testing.T) {
},
expected: nil,
},
{
desc: "should return nil when no server IPs",
service: rancherData{
Labels: map[string]string{
label.TraefikWeight: "7",
},
Containers: []string{""},
Health: "healthy",
State: "active",
},
expected: nil,
},
{
desc: "should use default weight when invalid weight value",
service: rancherData{