Cleanup on error in ProgramExternalConnectivity

Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
Alessandro Boch 2016-09-02 10:08:09 -07:00
parent 2a1ea8a642
commit bace4fb6ff
1 changed files with 10 additions and 1 deletions

View File

@ -1243,8 +1243,17 @@ func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string
return err
}
defer func() {
if err != nil {
if e := network.releasePorts(endpoint); e != nil {
logrus.Errorf("Failed to release ports allocated for the bridge endpoint %s on failure %v because of %v",
eid, err, e)
}
endpoint.portMapping = nil
}
}()
if err = d.storeUpdate(endpoint); err != nil {
endpoint.portMapping = nil
return fmt.Errorf("failed to update bridge endpoint %s to store: %v", endpoint.id[0:7], err)
}