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:
parent
77e06fda0c
commit
ae158b371c
1 changed files with 2 additions and 2 deletions
|
@ -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()
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Reference in a new issue