Save endpoint config only if endpoint creation succeeds

- Currently it is being save upfront...

Signed-off-by: Alessandro Boch <aboch@docker.com>
Upstream-commit: 733245b2e7517b88cdfb188f9d8418f29bca6338
Component: engine
This commit is contained in:
Alessandro Boch
2016-01-25 11:14:29 -08:00
parent d3b74e9005
commit 6f75e7937c
3 changed files with 21 additions and 7 deletions

View File

@ -265,7 +265,7 @@ func (container *Container) BuildJoinOptions(n libnetwork.Network) ([]libnetwork
}
// BuildCreateEndpointOptions builds endpoint options from a given network.
func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network) ([]libnetwork.EndpointOption, error) {
func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network, epConfig *network.EndpointSettings) ([]libnetwork.EndpointOption, error) {
var (
portSpecs = make(nat.PortSet)
bindings = make(nat.PortMap)
@ -278,7 +278,7 @@ func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network) ([]
createOptions = append(createOptions, libnetwork.CreateOptionAnonymous())
}
if epConfig, ok := container.NetworkSettings.Networks[n.Name()]; ok {
if epConfig != nil {
ipam := epConfig.IPAMConfig
if ipam != nil && (ipam.IPv4Address != "" || ipam.IPv6Address != "") {
createOptions = append(createOptions,