From c39ac9c05e53bbf58b096d814dbdabb783b0f14b Mon Sep 17 00:00:00 2001 From: Trapier Marshall Date: Tue, 3 Mar 2020 19:16:51 -0500 Subject: [PATCH] Cleanup VFP during overlay network removal Deleting a network sandbox on Linux implicitly clears OS (ipvs) load balancer state. Deleting an HNS network on Windows by contrast does not inherently remove its corresponding VFP load balancers. The method to remove load balancers belongs to the network and so must be called prior to or while deleting a network. This commit reverts one line from ea2fa208597e2dca2ae361ad51332d42f87e93d4, reintroducing a call to explicitly remove backend load balancers during network removal. Signed-off-by: Trapier Marshall --- libnetwork/network.go | 4 ++++ libnetwork/service_common.go | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libnetwork/network.go b/libnetwork/network.go index 9cf335a1b9..778c62a6e6 100644 --- a/libnetwork/network.go +++ b/libnetwork/network.go @@ -1088,6 +1088,10 @@ func (n *network) delete(force bool, rmLBEndpoint bool) error { // Cleanup the service discovery for this network c.cleanupServiceDiscovery(n.ID()) + // Cleanup the load balancer. On Windows this call is required + // to remove remote loadbalancers in VFP. + c.cleanupServiceBindings(n.ID()) + removeFromStore: // deleteFromStore performs an atomic delete operation and the // network.epCnt will help prevent any possible diff --git a/libnetwork/service_common.go b/libnetwork/service_common.go index 73358134b8..b6d79cce35 100644 --- a/libnetwork/service_common.go +++ b/libnetwork/service_common.go @@ -369,9 +369,11 @@ func (c *controller) rmServiceBinding(svcName, svcID, nID, eID, containerName st // sandboxes in the network only if the vip is valid. if entries == 0 { // The network may well have been deleted before the last - // of the service bindings. That's ok, because removing - // the network sandbox implicitly removes the backend - // service bindings. + // of the service bindings. That's ok on Linux because + // removing the network sandbox implicitly removes the + // backend service bindings. Windows VFP cleanup requires + // calling cleanupServiceBindings on the network prior to + // deleting the network, performed by network.delete. n, err := c.NetworkByID(nID) if err == nil { n.(*network).rmLBBackend(ip, lb, rmService, fullRemove)