1
0
Fork 0
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:
Tibor Vass 2020-06-05 09:55:54 -07:00 committed by GitHub
commit 5ffd677824
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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