1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #1375 from mrjana/lb

Do not add ingress loadbalancer on service tasks
This commit is contained in:
Santhosh Manohar 2016-08-04 18:45:51 -07:00 committed by GitHub
commit 0229451f3d

View file

@ -261,7 +261,7 @@ func (sb *sandbox) populateLoadbalancers(ep *endpoint) {
addService := true addService := true
for _, ip := range lb.backEnds { for _, ip := range lb.backEnds {
sb.addLBBackend(ip, lb.vip, lb.fwMark, lb.service.ingressPorts, sb.addLBBackend(ip, lb.vip, lb.fwMark, lb.service.ingressPorts,
eIP, gwIP, addService) eIP, gwIP, addService, n.ingress)
addService = false addService = false
} }
lb.service.Unlock() lb.service.Unlock()
@ -284,7 +284,7 @@ func (n *network) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*Po
gwIP = ep.Iface().Address().IP gwIP = ep.Iface().Address().IP
} }
sb.addLBBackend(ip, vip, fwMark, ingressPorts, ep.Iface().Address(), gwIP, addService) sb.addLBBackend(ip, vip, fwMark, ingressPorts, ep.Iface().Address(), gwIP, addService, n.ingress)
} }
return false return false
@ -307,7 +307,7 @@ func (n *network) rmLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*Por
gwIP = ep.Iface().Address().IP gwIP = ep.Iface().Address().IP
} }
sb.rmLBBackend(ip, vip, fwMark, ingressPorts, ep.Iface().Address(), gwIP, rmService) sb.rmLBBackend(ip, vip, fwMark, ingressPorts, ep.Iface().Address(), gwIP, rmService, n.ingress)
} }
return false return false
@ -315,11 +315,15 @@ func (n *network) rmLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*Por
} }
// Add loadbalancer backend into one connected sandbox. // 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) { func (sb *sandbox) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*PortConfig, eIP *net.IPNet, gwIP net.IP, addService bool, isIngressNetwork bool) {
if sb.osSbox == nil { if sb.osSbox == nil {
return return
} }
if isIngressNetwork && !sb.ingress {
return
}
i, err := ipvs.New(sb.Key()) i, err := ipvs.New(sb.Key())
if err != nil { if err != nil {
logrus.Errorf("Failed to create an ipvs handle for sbox %s: %v", sb.Key(), err) logrus.Errorf("Failed to create an ipvs handle for sbox %s: %v", sb.Key(), err)
@ -370,11 +374,15 @@ func (sb *sandbox) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*P
} }
// Remove loadbalancer backend from one connected sandbox. // Remove loadbalancer backend from one connected sandbox.
func (sb *sandbox) rmLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*PortConfig, eIP *net.IPNet, gwIP net.IP, rmService bool) { func (sb *sandbox) rmLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*PortConfig, eIP *net.IPNet, gwIP net.IP, rmService bool, isIngressNetwork bool) {
if sb.osSbox == nil { if sb.osSbox == nil {
return return
} }
if isIngressNetwork && !sb.ingress {
return
}
i, err := ipvs.New(sb.Key()) i, err := ipvs.New(sb.Key())
if err != nil { if err != nil {
logrus.Errorf("Failed to create an ipvs handle for sbox %s: %v", sb.Key(), err) logrus.Errorf("Failed to create an ipvs handle for sbox %s: %v", sb.Key(), err)