@@ -177,13 +177,18 @@ func (sb *sandbox) Delete() error {
177177 continue
178178 }
179179
180- if err := ep .Leave (sb ); err != nil {
180+ // Retain the sanbdox if we can't obtain the network from store.
181+ if _ , err := c .getNetworkFromStore (ep .getNetwork ().ID ()); err != nil {
181182 retain = true
183+ log .Warnf ("Failed getting network for ep %s during sandbox %s delete: %v" , ep .ID (), sb .ID (), err )
184+ continue
185+ }
186+
187+ if err := ep .Leave (sb ); err != nil {
182188 log .Warnf ("Failed detaching sandbox %s from endpoint %s: %v\n " , sb .ID (), ep .ID (), err )
183189 }
184190
185191 if err := ep .Delete (); err != nil {
186- retain = true
187192 log .Warnf ("Failed deleting endpoint %s: %v\n " , ep .ID (), err )
188193 }
189194 }
@@ -455,7 +460,7 @@ func (sb *sandbox) populateNetworkResources(ep *endpoint) error {
455460 i := ep .iface
456461 ep .Unlock ()
457462
458- if i .srcName != "" {
463+ if i != nil && i .srcName != "" {
459464 var ifaceOptions []osl.IfaceOption
460465
461466 ifaceOptions = append (ifaceOptions , sb .osSbox .InterfaceOptions ().Address (i .addr ), sb .osSbox .InterfaceOptions ().Routes (i .routes ))
@@ -951,6 +956,11 @@ func OptionGeneric(generic map[string]interface{}) SandboxOption {
951956func (eh epHeap ) Len () int { return len (eh ) }
952957
953958func (eh epHeap ) Less (i , j int ) bool {
959+ var (
960+ cip , cjp int
961+ ok bool
962+ )
963+
954964 ci , _ := eh [i ].getSandbox ()
955965 cj , _ := eh [j ].getSandbox ()
956966
@@ -965,14 +975,20 @@ func (eh epHeap) Less(i, j int) bool {
965975 return true
966976 }
967977
968- cip , ok := ci .epPriority [eh [i ].ID ()]
969- if ! ok {
970- cip = 0
978+ if ci != nil {
979+ cip , ok = ci .epPriority [eh [i ].ID ()]
980+ if ! ok {
981+ cip = 0
982+ }
971983 }
972- cjp , ok := cj .epPriority [eh [j ].ID ()]
973- if ! ok {
974- cjp = 0
984+
985+ if cj != nil {
986+ cjp , ok = cj .epPriority [eh [j ].ID ()]
987+ if ! ok {
988+ cjp = 0
989+ }
975990 }
991+
976992 if cip == cjp {
977993 return eh [i ].network .Name () < eh [j ].network .Name ()
978994 }
0 commit comments