Browse Source

Merge pull request #2449 from espensuenson/bugfix_getnetworkfromstore

Fixed getNetworkFromStore, which returned an incorrect struct
elangovan sivanandam 5 năm trước cách đây
mục cha
commit
e481dc9fad
1 tập tin đã thay đổi với 7 bổ sung22 xóa
  1. 7 22
      libnetwork/store.go

+ 7 - 22
libnetwork/store.go

@@ -80,30 +80,15 @@ func (c *controller) getStores() []datastore.DataStore {
 }
 }
 
 
 func (c *controller) getNetworkFromStore(nid string) (*network, error) {
 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
-		}
-
-		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()
+	ns, err := c.getNetworksFromStore()
+	if err != nil {
+		return nil, err
+	}
+	for _, n := range ns {
+		if n.id == nid {
+			return n, nil
 		}
 		}
-		return n, nil
 	}
 	}
-
 	return nil, fmt.Errorf("network %s not found", nid)
 	return nil, fmt.Errorf("network %s not found", nid)
 }
 }