Skip to content

Commit f5e0618

Browse files
authored
Merge pull request #2449 from espensuenson/bugfix_getnetworkfromstore
Fixed getNetworkFromStore, which returned an incorrect struct
2 parents 27a47ab + a35a770 commit f5e0618

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

store.go

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -80,30 +80,15 @@ func (c *controller) getStores() []datastore.DataStore {
8080
}
8181

8282
func (c *controller) getNetworkFromStore(nid string) (*network, error) {
83-
for _, store := range c.getStores() {
84-
n := &network{id: nid, ctrlr: c}
85-
err := store.GetObject(datastore.Key(n.Key()...), n)
86-
// Continue searching in the next store if the key is not found in this store
87-
if err != nil {
88-
if err != datastore.ErrKeyNotFound {
89-
logrus.Debugf("could not find network %s: %v", nid, err)
90-
}
91-
continue
92-
}
93-
94-
ec := &endpointCnt{n: n}
95-
err = store.GetObject(datastore.Key(ec.Key()...), ec)
96-
if err != nil && !n.inDelete {
97-
return nil, fmt.Errorf("could not find endpoint count for network %s: %v", n.Name(), err)
98-
}
99-
100-
n.epCnt = ec
101-
if n.scope == "" {
102-
n.scope = store.Scope()
83+
ns, err := c.getNetworksFromStore()
84+
if err != nil {
85+
return nil, err
86+
}
87+
for _, n := range ns {
88+
if n.id == nid {
89+
return n, nil
10390
}
104-
return n, nil
10591
}
106-
10792
return nil, fmt.Errorf("network %s not found", nid)
10893
}
10994

0 commit comments

Comments
 (0)