fix: metric with services LB.

This commit is contained in:
Ludovic Fernandez 2019-11-12 10:24:05 +01:00 committed by Traefiker Bot
parent 229402594f
commit 7536f5e83c
2 changed files with 9 additions and 2 deletions

View file

@ -229,8 +229,10 @@ func OnConfigurationUpdate(dynConf dynamic.Configurations, entryPoints []string)
for serviceName, service := range config.HTTP.Services {
dynamicConfig.services[fmt.Sprintf("%s@%s", serviceName, key)] = make(map[string]bool)
for _, server := range service.LoadBalancer.Servers {
dynamicConfig.services[fmt.Sprintf("%s@%s", serviceName, key)][server.URL] = true
if service.LoadBalancer != nil {
for _, server := range service.LoadBalancer.Servers {
dynamicConfig.services[fmt.Sprintf("%s@%s", serviceName, key)][server.URL] = true
}
}
}
}

View file

@ -291,6 +291,11 @@ func TestPrometheusMetricRemoval(t *testing.T) {
th.WithLoadBalancerServices(th.WithService("bar",
th.WithServers(th.WithServer("http://localhost:9000"))),
),
func(cfg *dynamic.HTTPConfiguration) {
cfg.Services["fii"] = &dynamic.Service{
Weighted: &dynamic.WeightedRoundRobin{},
}
},
),
}