From a70909792a35d5837de11cec0f85a53f0e5ed8d7 Mon Sep 17 00:00:00 2001 From: Jana Radhakrishnan Date: Sat, 11 Jun 2016 19:19:16 -0700 Subject: [PATCH] Reserve IPAM pools before resource cleanup If the IPAM pools are not reserved before resource cleanup happens then the resource release will not happen correctly. Signed-off-by: Jana Radhakrishnan --- libnetwork/controller.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libnetwork/controller.go b/libnetwork/controller.go index 3033adc32a..551e888b40 100644 --- a/libnetwork/controller.go +++ b/libnetwork/controller.go @@ -203,12 +203,18 @@ func New(cfgOptions ...config.Option) (NetworkController, error) { } } + // Reserve pools first before doing cleanup. This is because + // if the pools are not populated properly, the cleanups of + // endpoint/network and sandbox below will not be able to + // release ip subnets and addresses properly into the pool + // because the pools won't exist. + c.reservePools() + + // Cleanup resources c.sandboxCleanup() c.cleanupLocalEndpoints() c.networkCleanup() - c.reservePools() - if err := c.startExternalKeyListener(); err != nil { return nil, err }