diff options
author | Alessandro Boch <aboch@docker.com> | 2017-02-01 14:55:39 -0800 |
---|---|---|
committer | Alessandro Boch <aboch@docker.com> | 2017-02-01 15:54:31 -0800 |
commit | 4e69afc4f3807e7111b4b6999a800faa41b94ac6 (patch) | |
tree | 050b7c134e48ee54da67d17af6cee6798a6a883d /libnetwork/service_linux.go | |
parent | f318ddacdb60875fa99a2a08fe8226af2bf8cb07 (diff) | |
download | docker-4e69afc4f3807e7111b4b6999a800faa41b94ac6.tar.gz |
Make virtual service programming more robust
- Do not relay on software flags to decide when to create the
virtual service. Instead query the kernel for presence.
So that it cannot happen that a real server creation
fails because the virtual server is missing.
Signed-off-by: Alessandro Boch <aboch@docker.com>
Diffstat (limited to 'libnetwork/service_linux.go')
-rw-r--r-- | libnetwork/service_linux.go | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/libnetwork/service_linux.go b/libnetwork/service_linux.go index 3087639f31..b095d2b799 100644 --- a/libnetwork/service_linux.go +++ b/libnetwork/service_linux.go @@ -97,20 +97,16 @@ func (sb *sandbox) populateLoadbalancers(ep *endpoint) { } lb.service.Lock() - addService := true for _, ip := range lb.backEnds { - sb.addLBBackend(ip, lb.vip, lb.fwMark, lb.service.ingressPorts, - eIP, gwIP, addService, n.ingress) - addService = false + sb.addLBBackend(ip, lb.vip, lb.fwMark, lb.service.ingressPorts, eIP, gwIP, n.ingress) } lb.service.Unlock() } } // Add loadbalancer backend to all sandboxes which has a connection to -// this network. If needed add the service as well, as specified by -// the addService bool. -func (n *network) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*PortConfig, addService bool) { +// this network. If needed add the service as well. +func (n *network) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*PortConfig) { n.WalkEndpoints(func(e Endpoint) bool { ep := e.(*endpoint) if sb, ok := ep.getSandbox(); ok { @@ -123,7 +119,7 @@ func (n *network) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*Po gwIP = ep.Iface().Address().IP } - sb.addLBBackend(ip, vip, fwMark, ingressPorts, ep.Iface().Address(), gwIP, addService, n.ingress) + sb.addLBBackend(ip, vip, fwMark, ingressPorts, ep.Iface().Address(), gwIP, n.ingress) } return false @@ -154,7 +150,7 @@ func (n *network) rmLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*Por } // Add loadbalancer backend into one connected sandbox. -func (sb *sandbox) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*PortConfig, eIP *net.IPNet, gwIP net.IP, addService bool, isIngressNetwork bool) { +func (sb *sandbox) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*PortConfig, eIP *net.IPNet, gwIP net.IP, isIngressNetwork bool) { if sb.osSbox == nil { return } @@ -176,7 +172,7 @@ func (sb *sandbox) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*P SchedName: ipvs.RoundRobin, } - if addService { + if !i.IsServicePresent(s) { var filteredPorts []*PortConfig if sb.ingress { filteredPorts = filterPortConfigs(ingressPorts, false) |