Skip to content

Commit ae158b3

Browse files
committed
allocateNetwork: fix network sandbox not cleaned up on failure
The defer function was checking for the local `err` variable, not on the error that was returned by the function. As a result, the sandbox would never be cleaned up for containers that used "none" networking, and a failiure occured during setup. Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit b98b8df) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 77e06fd commit ae158b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

daemon/container_operations.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ func (daemon *Daemon) updateContainerNetworkSettings(container *container.Contai
509509
}
510510
}
511511

512-
func (daemon *Daemon) allocateNetwork(container *container.Container) error {
512+
func (daemon *Daemon) allocateNetwork(container *container.Container) (retErr error) {
513513
start := time.Now()
514514
controller := daemon.netController
515515

@@ -577,7 +577,7 @@ func (daemon *Daemon) allocateNetwork(container *container.Container) error {
577577
}
578578
updateSandboxNetworkSettings(container, sb)
579579
defer func() {
580-
if err != nil {
580+
if retErr != nil {
581581
sb.Delete()
582582
}
583583
}()

0 commit comments

Comments
 (0)