From 849712f35dbde38cceda15e619cb9cbacedb8b2d Mon Sep 17 00:00:00 2001 From: Madhu Venugopal Date: Wed, 27 Jul 2016 00:55:46 -0700 Subject: [PATCH] Better error handling in restoring sandbox states Signed-off-by: Madhu Venugopal --- libnetwork/sandbox.go | 6 ++++++ libnetwork/sandbox_store.go | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/libnetwork/sandbox.go b/libnetwork/sandbox.go index a4a8933e28..a0667b46aa 100644 --- a/libnetwork/sandbox.go +++ b/libnetwork/sandbox.go @@ -726,6 +726,12 @@ func (sb *sandbox) restoreOslSandbox() error { joinInfo := ep.joinInfo i := ep.iface ep.Unlock() + + if i == nil { + log.Errorf("error restoring endpoint %s for container %s", ep.Name(), sb.ContainerID()) + continue + } + ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().Address(i.addr), sb.osSbox.InterfaceOptions().Routes(i.routes)) if i.addrv6 != nil && i.addrv6.IP.To16() != nil { ifaceOptions = append(ifaceOptions, sb.osSbox.InterfaceOptions().AddressIPv6(i.addrv6)) diff --git a/libnetwork/sandbox_store.go b/libnetwork/sandbox_store.go index 5b963e71c3..58a939c3ea 100644 --- a/libnetwork/sandbox_store.go +++ b/libnetwork/sandbox_store.go @@ -245,6 +245,10 @@ func (c *controller) sandboxCleanup(activeSandboxes map[string]interface{}) { ep = &endpoint{id: eps.Eid, network: n, sandboxID: sbs.ID} } } + if _, ok := activeSandboxes[sb.ID()]; ok && err != nil { + logrus.Errorf("failed to restore endpoint %s in %s for container %s due to %v", eps.Eid, eps.Nid, sb.ContainerID(), err) + continue + } heap.Push(&sb.endpoints, ep) }