diff --git a/libnetwork/controller.go b/libnetwork/controller.go index d48ac607e1..24494ae834 100644 --- a/libnetwork/controller.go +++ b/libnetwork/controller.go @@ -849,13 +849,22 @@ addToStore: return network, nil } + joinCluster(network) + defer func() { + if err != nil { + network.cancelDriverWatches() + if e := network.leaveCluster(); e != nil { + logrus.Warnf("Failed to leave agent cluster on network %s on failure (%v): %v", network.name, err, e) + } + } + }() + if len(network.loadBalancerIP) != 0 { if err = network.createLoadBalancerSandbox(); err != nil { return nil, err } } - joinCluster(network) if !c.isDistributedControl() { c.Lock() arrangeIngressFilterRule() diff --git a/libnetwork/store.go b/libnetwork/store.go index da7ac1dea6..95943f6f45 100644 --- a/libnetwork/store.go +++ b/libnetwork/store.go @@ -256,7 +256,7 @@ retry: if err := cs.GetObject(datastore.Key(kvObject.Key()...), kvObject); err != nil { return fmt.Errorf("could not update the kvobject to latest when trying to delete: %v", err) } - logrus.Errorf("Error (%v) deleting object %v, retrying....", err, kvObject.Key()) + logrus.Warnf("Error (%v) deleting object %v, retrying....", err, kvObject.Key()) goto retry } return err