浏览代码

libnetwork: Controller.cleanupLocalEndpoints: return errors

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 1 年之前
父节点
当前提交
a8ea752a93
共有 2 个文件被更改,包括 7 次插入4 次删除
  1. 3 1
      libnetwork/controller.go
  2. 4 3
      libnetwork/endpoint.go

+ 3 - 1
libnetwork/controller.go

@@ -151,7 +151,9 @@ func New(cfgOptions ...config.Option) (*Controller, error) {
 	if err := c.sandboxCleanup(c.cfg.ActiveSandboxes); err != nil {
 		log.G(context.TODO()).WithError(err).Error("error during sandbox cleanup")
 	}
-	c.cleanupLocalEndpoints()
+	if err := c.cleanupLocalEndpoints(); err != nil {
+		log.G(context.TODO()).WithError(err).Warnf("error during endpoint cleanup")
+	}
 	c.networkCleanup()
 
 	if err := c.startExternalKeyListener(); err != nil {

+ 4 - 3
libnetwork/endpoint.go

@@ -1144,7 +1144,7 @@ func (ep *Endpoint) releaseAddress() {
 	}
 }
 
-func (c *Controller) cleanupLocalEndpoints() {
+func (c *Controller) cleanupLocalEndpoints() error {
 	// Get used endpoints
 	eps := make(map[string]interface{})
 	for _, sb := range c.sandboxes {
@@ -1154,8 +1154,7 @@ func (c *Controller) cleanupLocalEndpoints() {
 	}
 	nl, err := c.getNetworks()
 	if err != nil {
-		log.G(context.TODO()).Warnf("Could not get list of networks during endpoint cleanup: %v", err)
-		return
+		return fmt.Errorf("could not get list of networks: %v", err)
 	}
 
 	for _, n := range nl {
@@ -1192,4 +1191,6 @@ func (c *Controller) cleanupLocalEndpoints() {
 			}
 		}
 	}
+
+	return nil
 }