kv: Ignore backend servers with no url
Currently with a kv tree like: /traefik/backends/b1/servers/ẁeb1 /traefik/backends/b1/servers/web2 /traefik/backends/b1/servers/web2/url Traefik would try to forward traffic to web1, which is impossible as traefik doesn't know the url of web1. This commit solve that, by ignoring backend server with no url "key" when generating the config. This is very useful, for people who use etcd TTL feature. They can then just "renew" the url key every X second, and if the server goes down, it is automatic removed from traefik after the TTL.
This commit is contained in:
parent
69c31276f2
commit
020a8e31ab
1 changed files with 3 additions and 0 deletions
|
@ -162,6 +162,9 @@ func (provider *Kv) list(keys ...string) []string {
|
||||||
func (provider *Kv) listServers(backend string) []string {
|
func (provider *Kv) listServers(backend string) []string {
|
||||||
serverNames := provider.list(backend, "/servers/")
|
serverNames := provider.list(backend, "/servers/")
|
||||||
return fun.Filter(func(serverName string) bool {
|
return fun.Filter(func(serverName string) bool {
|
||||||
|
if _, err := provider.kvclient.Get(fmt.Sprint(serverName, "/url")); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return provider.checkConstraints(serverName, "/tags")
|
return provider.checkConstraints(serverName, "/tags")
|
||||||
}, serverNames).([]string)
|
}, serverNames).([]string)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue