1
0
mirror of https://github.com/docker/cli.git synced 2026-01-26 15:41:42 +03:00

Fix a corner case issue when daemon panics

There is an extreme corner case where when the daemon
panics at the same time as a container is stopping
and cleaning up the sandbox and the sandbox may have been
left with an inconsistent state. This libnetwork vendoring
fixes that case.

Vendoring in libnetwork @ 5305ea570b85d61dd0fd261cd7e1680da1884678

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
Upstream-commit: 79cffa5ce4a71b29eed66e26c1fb7f153be5c045
Component: engine
This commit is contained in:
Jana Radhakrishnan
2015-11-02 18:37:35 -08:00
parent 2f6185bd11
commit bafe2d42bf
2 changed files with 26 additions and 10 deletions

View File

@@ -177,13 +177,18 @@ func (sb *sandbox) Delete() error {
continue
}
if err := ep.Leave(sb); err != nil {
// Retain the sanbdox if we can't obtain the network from store.
if _, err := c.getNetworkFromStore(ep.getNetwork().ID()); err != nil {
retain = true
log.Warnf("Failed getting network for ep %s during sandbox %s delete: %v", ep.ID(), sb.ID(), err)
continue
}
if err := ep.Leave(sb); err != nil {
log.Warnf("Failed detaching sandbox %s from endpoint %s: %v\n", sb.ID(), ep.ID(), err)
}
if err := ep.Delete(); err != nil {
retain = true
log.Warnf("Failed deleting endpoint %s: %v\n", ep.ID(), err)
}
}
@@ -455,7 +460,7 @@ func (sb *sandbox) populateNetworkResources(ep *endpoint) error {
i := ep.iface
ep.Unlock()
if i.srcName != "" {
if i != nil && i.srcName != "" {
var ifaceOptions []osl.IfaceOption
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 {
func (eh epHeap) Len() int { return len(eh) }
func (eh epHeap) Less(i, j int) bool {
var (
cip, cjp int
ok bool
)
ci, _ := eh[i].getSandbox()
cj, _ := eh[j].getSandbox()
@@ -965,14 +975,20 @@ func (eh epHeap) Less(i, j int) bool {
return true
}
cip, ok := ci.epPriority[eh[i].ID()]
if !ok {
cip = 0
if ci != nil {
cip, ok = ci.epPriority[eh[i].ID()]
if !ok {
cip = 0
}
}
cjp, ok := cj.epPriority[eh[j].ID()]
if !ok {
cjp = 0
if cj != nil {
cjp, ok = cj.epPriority[eh[j].ID()]
if !ok {
cjp = 0
}
}
if cip == cjp {
return eh[i].network.Name() < eh[j].network.Name()
}