Merge pull request #41081 from thaJeztah/19.03_backport_fix_sandbox_cleanup

[19.03 backport] allocateNetwork: fix network sandbox not cleaned up on failure
This commit is contained in:
Akihiro Suda 2020-07-26 16:17:32 +09:00 committed by GitHub
commit 2d4bfdc789
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()
}
}()