summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCory Snider <csnider@mirantis.com>2023-04-11 19:00:59 -0400
committerSebastiaan van Stijn <github@gone.nl>2023-04-21 12:47:01 +0200
commitc82be354122fd936f972427bafb9fe6928fc36c5 (patch)
treecc978371f13064d2fe5be798bcb91b4a3414a34f
parent8fdca288c5c9d84dc27ed65b4e67c885452e27e9 (diff)
downloaddocker-c82be354122fd936f972427bafb9fe6928fc36c5.tar.gz
libnetwork: clean up inDelete network atomically
The (*network).ipamRelease function nils out the network's IPAM info fields, putting the network struct into an inconsistent state. The network-restore startup code panics if it tries to restore a network from a struct which has fewer IPAM config entries than IPAM info entries. Therefore (*network).delete contains a critical section: by persisting the network to the store after ipamRelease(), the datastore will contain an inconsistent network until the deletion operation completes and finishes deleting the network from the datastore. If for any reason the deletion operation is interrupted between ipamRelease() and deleteFromStore(), the daemon will crash on startup when it tries to restore the network. Updating the datastore after releasing the network's IPAM pools may have served a purpose in the past, when a global datastore was used for intra-cluster communication and the IPAM allocator had persistent global state, but nowadays there is no global datastore and the IPAM allocator has no persistent state whatsoever. Remove the vestigial datastore update as it is no longer necessary and only serves to cause problems. If the network deletion is interrupted before the network is deleted from the datastore, the deletion will resume during the next daemon startup, including releasing the IPAM pools. Signed-off-by: Cory Snider <csnider@mirantis.com> (cherry picked from commit c957ad006747df00730ce3aeaf4ac9df14baa998) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
-rw-r--r--libnetwork/network.go3
1 files changed, 0 insertions, 3 deletions
diff --git a/libnetwork/network.go b/libnetwork/network.go
index 3e04cafcd5..5ca80feb4f 100644
--- a/libnetwork/network.go
+++ b/libnetwork/network.go
@@ -1061,9 +1061,6 @@ func (n *network) delete(force bool, rmLBEndpoint bool) error {
}
n.ipamRelease()
- if err = c.updateToStore(n); err != nil {
- logrus.Warnf("Failed to update store after ipam release for network %s (%s): %v", n.Name(), n.ID(), err)
- }
// We are about to delete the network. Leave the gossip
// cluster for the network to stop all incoming network