|
@@ -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
|