From 43a3151db260b561eb6abe5c3aee2760a002a242 Mon Sep 17 00:00:00 2001 From: Espen Suenson Date: Wed, 11 Sep 2019 21:09:13 +0200 Subject: [PATCH] Fixed getNetworkFromStore, which returned incorrect network information - notably, the 'resolver' field was empty. This fixes https://github.com/moby/moby/issues/38901 Signed-off-by: Espen Suenson --- libnetwork/store.go | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/libnetwork/store.go b/libnetwork/store.go index 0a7c5754d3..37f479e397 100644 --- a/libnetwork/store.go +++ b/libnetwork/store.go @@ -80,30 +80,12 @@ func (c *controller) getStores() []datastore.DataStore { } func (c *controller) getNetworkFromStore(nid string) (*network, error) { - for _, store := range c.getStores() { - n := &network{id: nid, ctrlr: c} - err := store.GetObject(datastore.Key(n.Key()...), n) - // Continue searching in the next store if the key is not found in this store - if err != nil { - if err != datastore.ErrKeyNotFound { - logrus.Debugf("could not find network %s: %v", nid, err) - } - continue + ns, err := c.getNetworksFromStore() + for _, n := range ns { + if n.id == nid { + return n, err } - - ec := &endpointCnt{n: n} - err = store.GetObject(datastore.Key(ec.Key()...), ec) - if err != nil && !n.inDelete { - return nil, fmt.Errorf("could not find endpoint count for network %s: %v", n.Name(), err) - } - - n.epCnt = ec - if n.scope == "" { - n.scope = store.Scope() - } - return n, nil } - return nil, fmt.Errorf("network %s not found", nid) }