diff options
author | Jana Radhakrishnan <mrjana@docker.com> | 2016-11-02 09:45:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-02 09:45:14 -0700 |
commit | b1e753137fcdb14c7be769d5a0b8a3edb5a6d32f (patch) | |
tree | 0570cf417d760666a2a5b413f96b4977d569c822 /libnetwork/service_linux.go | |
parent | b249e8afe0a6c4ca1a244f7c5516e39d72407603 (diff) | |
parent | ddc74ffcedbdf927a6855db611360f9c06658be8 (diff) | |
download | docker-b1e753137fcdb14c7be769d5a0b8a3edb5a6d32f.tar.gz |
Merge pull request #1501 from sanimej/vip
Enable ping for service vip address
Diffstat (limited to 'libnetwork/service_linux.go')
-rw-r--r-- | libnetwork/service_linux.go | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/libnetwork/service_linux.go b/libnetwork/service_linux.go index a3f49c28f8..669eda9fb3 100644 --- a/libnetwork/service_linux.go +++ b/libnetwork/service_linux.go @@ -317,6 +317,14 @@ func (sb *sandbox) populateLoadbalancers(ep *endpoint) { for _, ip := range lb.backEnds { sb.addLBBackend(ip, lb.vip, lb.fwMark, lb.service.ingressPorts, eIP, gwIP, addService, n.ingress) + // For a new service program the vip as an alias on the task's sandbox interface + // connected to this network. + if !addService { + continue + } + if err := ep.setAliasIP(sb, lb.vip, true); err != nil { + logrus.Errorf("Adding Service VIP %v to ep %v(%v) failed: %v", lb.vip, ep.ID(), ep.Name(), err) + } addService = false } lb.service.Unlock() @@ -340,8 +348,16 @@ func (n *network) addLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*Po } sb.addLBBackend(ip, vip, fwMark, ingressPorts, ep.Iface().Address(), gwIP, addService, n.ingress) - } + // For a new service program the vip as an alias on the task's sandbox interface + // connected to this network. + if !addService { + return false + } + if err := ep.setAliasIP(sb, vip, true); err != nil { + logrus.Errorf("Adding Service VIP %v to ep %v(%v) failed: %v", vip, ep.ID(), ep.Name(), err) + } + } return false }) } @@ -363,8 +379,16 @@ func (n *network) rmLBBackend(ip, vip net.IP, fwMark uint32, ingressPorts []*Por } sb.rmLBBackend(ip, vip, fwMark, ingressPorts, ep.Iface().Address(), gwIP, rmService, n.ingress) - } + // If the service is being remove its vip alias on on the task's sandbox interface + // has to be removed as well. + if !rmService { + return false + } + if err := ep.setAliasIP(sb, vip, false); err != nil { + logrus.Errorf("Removing Service VIP %v from ep %v(%v) failed: %v", vip, ep.ID(), ep.Name(), err) + } + } return false }) } |