libnetwork: Controller.sandboxCleanup: return errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
e3975fba84
commit
2e60051c92
2 changed files with 10 additions and 7 deletions
|
@ -148,7 +148,9 @@ func New(cfgOptions ...config.Option) (*Controller, error) {
|
|||
c.reservePools()
|
||||
|
||||
// Cleanup resources
|
||||
c.sandboxCleanup(c.cfg.ActiveSandboxes)
|
||||
if err := c.sandboxCleanup(c.cfg.ActiveSandboxes); err != nil {
|
||||
log.G(context.TODO()).WithError(err).Error("error during sandbox cleanup")
|
||||
}
|
||||
c.cleanupLocalEndpoints()
|
||||
c.networkCleanup()
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package libnetwork
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
|
@ -171,21 +172,19 @@ func (sb *Sandbox) storeDelete() error {
|
|||
})
|
||||
}
|
||||
|
||||
func (c *Controller) sandboxCleanup(activeSandboxes map[string]interface{}) {
|
||||
func (c *Controller) sandboxCleanup(activeSandboxes map[string]interface{}) error {
|
||||
store := c.getStore()
|
||||
if store == nil {
|
||||
log.G(context.TODO()).Error("Could not find local scope store while trying to cleanup sandboxes")
|
||||
return
|
||||
return fmt.Errorf("could not find local scope store")
|
||||
}
|
||||
|
||||
sandboxStates, err := store.List(datastore.Key(sandboxPrefix), &sbState{c: c})
|
||||
if err != nil {
|
||||
if err == datastore.ErrKeyNotFound {
|
||||
// It's normal for no sandboxes to be found. Just bail out.
|
||||
return
|
||||
return nil
|
||||
}
|
||||
log.G(context.TODO()).Errorf("failed to get sandboxes for scope %s: %v", store.Scope(), err)
|
||||
return
|
||||
return fmt.Errorf("failed to get sandboxes for scope %s: %v", store.Scope(), err)
|
||||
}
|
||||
|
||||
for _, s := range sandboxStates {
|
||||
|
@ -285,4 +284,6 @@ func (c *Controller) sandboxCleanup(activeSandboxes map[string]interface{}) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue