mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #41020 from thaJeztah/fix_sandbox_cleanup
allocateNetwork: fix network sandbox not cleaned up on failure
This commit is contained in:
commit
5ffd677824
1 changed files with 7 additions and 5 deletions
|
@ -526,14 +526,16 @@ func (daemon *Daemon) updateContainerNetworkSettings(container *container.Contai
|
|||
}
|
||||
}
|
||||
|
||||
func (daemon *Daemon) allocateNetwork(container *container.Container) error {
|
||||
start := time.Now()
|
||||
controller := daemon.netController
|
||||
|
||||
func (daemon *Daemon) allocateNetwork(container *container.Container) (retErr error) {
|
||||
if daemon.netController == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
start = time.Now()
|
||||
controller = daemon.netController
|
||||
)
|
||||
|
||||
// Cleanup any stale sandbox left over due to ungraceful daemon shutdown
|
||||
if err := controller.SandboxDestroy(container.ID); err != nil {
|
||||
logrus.WithError(err).Errorf("failed to cleanup up stale network sandbox for container %s", container.ID)
|
||||
|
@ -594,7 +596,7 @@ func (daemon *Daemon) allocateNetwork(container *container.Container) error {
|
|||
}
|
||||
updateSandboxNetworkSettings(container, sb)
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if retErr != nil {
|
||||
sb.Delete()
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Reference in a new issue