daemon: buildCreateEndpointOptions: don't parse empty vip
Also keep network.ID() in a local variable to prevent locking the network twice. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
7d429125d2
commit
45de99aa06
1 changed files with 6 additions and 4 deletions
|
@ -840,9 +840,11 @@ func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, e
|
|||
}
|
||||
|
||||
if svcCfg := c.NetworkSettings.Service; svcCfg != nil {
|
||||
var vip string
|
||||
if svcCfg.VirtualAddresses[n.ID()] != nil {
|
||||
vip = svcCfg.VirtualAddresses[n.ID()].IPv4
|
||||
nwID := n.ID()
|
||||
|
||||
var vip net.IP
|
||||
if virtualAddress := svcCfg.VirtualAddresses[nwID]; virtualAddress != nil {
|
||||
vip = net.ParseIP(virtualAddress.IPv4)
|
||||
}
|
||||
|
||||
var portConfigs []*libnetwork.PortConfig
|
||||
|
@ -855,7 +857,7 @@ func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, e
|
|||
})
|
||||
}
|
||||
|
||||
createOptions = append(createOptions, libnetwork.CreateOptionService(svcCfg.Name, svcCfg.ID, net.ParseIP(vip), portConfigs, svcCfg.Aliases[n.ID()]))
|
||||
createOptions = append(createOptions, libnetwork.CreateOptionService(svcCfg.Name, svcCfg.ID, vip, portConfigs, svcCfg.Aliases[nwID]))
|
||||
}
|
||||
|
||||
if !containertypes.NetworkMode(n.Name()).IsUserDefined() {
|
||||
|
|
Loading…
Add table
Reference in a new issue