Network Allocation: Proper rollback in case of failure allocation.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2014-09-29 15:51:36 -07:00
Родитель 88e21c6a75
Коммит 103a4e0676
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -463,10 +463,12 @@ func (container *Container) allocateNetwork() error {
if container.Config.PortSpecs != nil {
if err := migratePortMappings(container.Config, container.hostConfig); err != nil {
eng.Job("release_interface", container.ID).Run()
return err
}
container.Config.PortSpecs = nil
if err := container.WriteHostConfig(); err != nil {
eng.Job("release_interface", container.ID).Run()
return err
}
}
@ -496,6 +498,7 @@ func (container *Container) allocateNetwork() error {
for port := range portSpecs {
if err := container.allocatePort(eng, port, bindings); err != nil {
eng.Job("release_interface", container.ID).Run()
return err
}
}
@ -1149,7 +1152,6 @@ func (container *Container) allocatePort(eng *engine.Engine, port nat.Port, bind
return err
}
if err := job.Run(); err != nil {
eng.Job("release_interface", container.ID).Run()
return err
}
b.HostIp = portEnv.Get("HostIP")