mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Dont fail the Get functions if there is an error in one of the stores
Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
a10c1e3460
commit
07bb3dcdba
1 changed files with 22 additions and 32 deletions
|
@ -60,12 +60,11 @@ func (c *controller) getNetworkFromStore(nid string) (*network, error) {
|
||||||
for _, store := range c.getStores() {
|
for _, store := range c.getStores() {
|
||||||
n := &network{id: nid, ctrlr: c}
|
n := &network{id: nid, ctrlr: c}
|
||||||
err := store.GetObject(datastore.Key(n.Key()...), n)
|
err := store.GetObject(datastore.Key(n.Key()...), n)
|
||||||
if err != nil && err != datastore.ErrKeyNotFound {
|
|
||||||
return nil, fmt.Errorf("could not find network %s: %v", nid, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Continue searching in the next store if the key is not found in this store
|
// Continue searching in the next store if the key is not found in this store
|
||||||
if err == datastore.ErrKeyNotFound {
|
if err != nil {
|
||||||
|
if err != datastore.ErrKeyNotFound {
|
||||||
|
log.Debugf("could not find network %s: %v", nid, err)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,13 +119,11 @@ func (c *controller) getNetworksFromStore() ([]*network, error) {
|
||||||
for _, store := range c.getStores() {
|
for _, store := range c.getStores() {
|
||||||
kvol, err := store.List(datastore.Key(datastore.NetworkKeyPrefix),
|
kvol, err := store.List(datastore.Key(datastore.NetworkKeyPrefix),
|
||||||
&network{ctrlr: c})
|
&network{ctrlr: c})
|
||||||
if err != nil && err != datastore.ErrKeyNotFound {
|
|
||||||
return nil, fmt.Errorf("failed to get networks for scope %s: %v",
|
|
||||||
store.Scope(), err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Continue searching in the next store if no keys found in this store
|
// Continue searching in the next store if no keys found in this store
|
||||||
if err == datastore.ErrKeyNotFound {
|
if err != nil {
|
||||||
|
if err != datastore.ErrKeyNotFound {
|
||||||
|
log.Debugf("failed to get networks for scope %s: %v", store.Scope(), err)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,22 +146,17 @@ func (c *controller) getNetworksFromStore() ([]*network, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) getEndpointFromStore(eid string) (*endpoint, error) {
|
func (n *network) getEndpointFromStore(eid string) (*endpoint, error) {
|
||||||
for _, store := range n.ctrlr.getStores() {
|
store := n.ctrlr.getStore(n.Scope())
|
||||||
ep := &endpoint{id: eid, network: n}
|
if store == nil {
|
||||||
err := store.GetObject(datastore.Key(ep.Key()...), ep)
|
return nil, fmt.Errorf("could not find endpoint %s: datastore not found for scope %s", eid, n.Scope())
|
||||||
if err != nil && err != datastore.ErrKeyNotFound {
|
|
||||||
return nil, fmt.Errorf("could not find endpoint %s: %v", eid, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Continue searching in the next store if the key is not found in this store
|
|
||||||
if err == datastore.ErrKeyNotFound {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
return ep, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("endpoint %s not found", eid)
|
ep := &endpoint{id: eid, network: n}
|
||||||
|
err := store.GetObject(datastore.Key(ep.Key()...), ep)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("could not find endpoint %s: %v", eid, err)
|
||||||
|
}
|
||||||
|
return ep, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) getEndpointsFromStore() ([]*endpoint, error) {
|
func (n *network) getEndpointsFromStore() ([]*endpoint, error) {
|
||||||
|
@ -173,14 +165,12 @@ func (n *network) getEndpointsFromStore() ([]*endpoint, error) {
|
||||||
tmp := endpoint{network: n}
|
tmp := endpoint{network: n}
|
||||||
for _, store := range n.getController().getStores() {
|
for _, store := range n.getController().getStores() {
|
||||||
kvol, err := store.List(datastore.Key(tmp.KeyPrefix()...), &endpoint{network: n})
|
kvol, err := store.List(datastore.Key(tmp.KeyPrefix()...), &endpoint{network: n})
|
||||||
if err != nil && err != datastore.ErrKeyNotFound {
|
|
||||||
return nil,
|
|
||||||
fmt.Errorf("failed to get endpoints for network %s scope %s: %v",
|
|
||||||
n.Name(), store.Scope(), err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Continue searching in the next store if no keys found in this store
|
// Continue searching in the next store if no keys found in this store
|
||||||
if err == datastore.ErrKeyNotFound {
|
if err != nil {
|
||||||
|
if err != datastore.ErrKeyNotFound {
|
||||||
|
log.Debugf("failed to get endpoints for network %s scope %s: %v",
|
||||||
|
n.Name(), store.Scope(), err)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue