store.getNetworksFromStore() remove unused error return
This function always returned `nil`, so we can remove the error return, and update other functions that were handling errors. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
b1729e8588
commit
07ed00102d
|
@ -1020,12 +1020,7 @@ func (c *controller) addNetwork(n *network) error {
|
||||||
func (c *controller) Networks() []Network {
|
func (c *controller) Networks() []Network {
|
||||||
var list []Network
|
var list []Network
|
||||||
|
|
||||||
networks, err := c.getNetworksFromStore()
|
for _, n := range c.getNetworksFromStore() {
|
||||||
if err != nil {
|
|
||||||
logrus.Error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, n := range networks {
|
|
||||||
if n.inDelete {
|
if n.inDelete {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,11 +80,7 @@ func (c *controller) getStores() []datastore.DataStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *controller) getNetworkFromStore(nid string) (*network, error) {
|
func (c *controller) getNetworkFromStore(nid string) (*network, error) {
|
||||||
ns, err := c.getNetworksFromStore()
|
for _, n := range c.getNetworksFromStore() {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
for _, n := range ns {
|
|
||||||
if n.id == nid {
|
if n.id == nid {
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
@ -128,12 +124,11 @@ func (c *controller) getNetworksForScope(scope string) ([]*network, error) {
|
||||||
return nl, nil
|
return nl, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *controller) getNetworksFromStore() ([]*network, error) {
|
func (c *controller) getNetworksFromStore() []*network {
|
||||||
var nl []*network
|
var nl []*network
|
||||||
|
|
||||||
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})
|
|
||||||
// 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 != nil {
|
if err != nil {
|
||||||
if err != datastore.ErrKeyNotFound {
|
if err != datastore.ErrKeyNotFound {
|
||||||
|
@ -143,11 +138,9 @@ func (c *controller) getNetworksFromStore() ([]*network, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
kvep, err := store.Map(datastore.Key(epCntKeyPrefix), &endpointCnt{})
|
kvep, err := store.Map(datastore.Key(epCntKeyPrefix), &endpointCnt{})
|
||||||
if err != nil {
|
if err != nil && err != datastore.ErrKeyNotFound {
|
||||||
if err != datastore.ErrKeyNotFound {
|
|
||||||
logrus.Warnf("failed to get endpoint_count map for scope %s: %v", store.Scope(), err)
|
logrus.Warnf("failed to get endpoint_count map for scope %s: %v", store.Scope(), err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for _, kvo := range kvol {
|
for _, kvo := range kvol {
|
||||||
n := kvo.(*network)
|
n := kvo.(*network)
|
||||||
|
@ -168,7 +161,7 @@ func (c *controller) getNetworksFromStore() ([]*network, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nl, nil
|
return nl
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) getEndpointFromStore(eid string) (*endpoint, error) {
|
func (n *network) getEndpointFromStore(eid string) (*endpoint, error) {
|
||||||
|
@ -455,13 +448,7 @@ func (c *controller) startWatch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *controller) networkCleanup() {
|
func (c *controller) networkCleanup() {
|
||||||
networks, err := c.getNetworksFromStore()
|
for _, n := range c.getNetworksFromStore() {
|
||||||
if err != nil {
|
|
||||||
logrus.Warnf("Could not retrieve networks from store(s) during network cleanup: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, n := range networks {
|
|
||||||
if n.inDelete {
|
if n.inDelete {
|
||||||
logrus.Infof("Removing stale network %s (%s)", n.Name(), n.ID())
|
logrus.Infof("Removing stale network %s (%s)", n.Name(), n.ID())
|
||||||
if err := n.delete(true, true); err != nil {
|
if err := n.delete(true, true); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue