mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
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 b98b8df886)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -509,7 +509,7 @@ func (daemon *Daemon) updateContainerNetworkSettings(container *container.Contai
|
||||
}
|
||||
}
|
||||
|
||||
func (daemon *Daemon) allocateNetwork(container *container.Container) error {
|
||||
func (daemon *Daemon) allocateNetwork(container *container.Container) (retErr error) {
|
||||
start := time.Now()
|
||||
controller := daemon.netController
|
||||
|
||||
@@ -577,7 +577,7 @@ func (daemon *Daemon) allocateNetwork(container *container.Container) error {
|
||||
}
|
||||
updateSandboxNetworkSettings(container, sb)
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if retErr != nil {
|
||||
sb.Delete()
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user