summaryrefslogtreecommitdiff
path: root/libnetwork/service_linux.go
diff options
context:
space:
mode:
authorChris Telfer <ctelfer@docker.com>2018-04-10 00:36:19 -0400
committerChris Telfer <ctelfer@docker.com>2018-06-28 12:08:18 -0400
commit85a3483b4b9307341afe2ddefb7eacc43e951ccb (patch)
tree63f38b20e819d248d2f22a10156992a76718e63a /libnetwork/service_linux.go
parent78b684a24a97b0bc6d9cc4f8b405ac9613cc385e (diff)
downloaddocker-85a3483b4b9307341afe2ddefb7eacc43e951ccb.tar.gz
Refactor [add|rm]LBBackend() to use lb struct
This was passing extra information and adding confusion about the purpose of the load balancing structure. Signed-off-by: Chris Telfer <ctelfer@docker.com>
Diffstat (limited to 'libnetwork/service_linux.go')
-rw-r--r--libnetwork/service_linux.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/libnetwork/service_linux.go b/libnetwork/service_linux.go
index a95ece8a08..bf6c0d4fb8 100644
--- a/libnetwork/service_linux.go
+++ b/libnetwork/service_linux.go
@@ -114,7 +114,10 @@ func (sb *sandbox) populateLoadbalancers(ep *endpoint) {
// Add loadbalancer backend to all sandboxes which has a connection to
// this network. If needed add the service as well.
-func (n *network) addLBBackend(ip, vip net.IP, lb *loadBalancer, ingressPorts []*PortConfig) {
+func (n *network) addLBBackend(ip net.IP, lb *loadBalancer) {
+ if len(lb.vip) == 0 {
+ return
+ }
n.WalkEndpoints(func(e Endpoint) bool {
ep := e.(*endpoint)
if sb, ok := ep.getSandbox(); ok {
@@ -127,7 +130,7 @@ func (n *network) addLBBackend(ip, vip net.IP, lb *loadBalancer, ingressPorts []
gwIP = ep.Iface().Address().IP
}
- sb.addLBBackend(ip, vip, lb.fwMark, ingressPorts, ep.Iface().Address(), gwIP, n.ingress)
+ sb.addLBBackend(ip, lb.vip, lb.fwMark, lb.service.ingressPorts, ep.Iface().Address(), gwIP, n.ingress)
}
return false
@@ -137,7 +140,10 @@ func (n *network) addLBBackend(ip, vip net.IP, lb *loadBalancer, ingressPorts []
// Remove loadbalancer backend from all sandboxes which has a
// connection to this network. If needed remove the service entry as
// well, as specified by the rmService bool.
-func (n *network) rmLBBackend(ip, vip net.IP, lb *loadBalancer, ingressPorts []*PortConfig, rmService bool, fullRemove bool) {
+func (n *network) rmLBBackend(ip net.IP, lb *loadBalancer, rmService bool, fullRemove bool) {
+ if len(lb.vip) == 0 {
+ return
+ }
n.WalkEndpoints(func(e Endpoint) bool {
ep := e.(*endpoint)
if sb, ok := ep.getSandbox(); ok {
@@ -150,7 +156,7 @@ func (n *network) rmLBBackend(ip, vip net.IP, lb *loadBalancer, ingressPorts []*
gwIP = ep.Iface().Address().IP
}
- sb.rmLBBackend(ip, vip, lb.fwMark, ingressPorts, ep.Iface().Address(), gwIP, rmService, fullRemove, n.ingress)
+ sb.rmLBBackend(ip, lb.vip, lb.fwMark, lb.service.ingressPorts, ep.Iface().Address(), gwIP, rmService, fullRemove, n.ingress)
}
return false