1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #26848 from miaoyq/del-a-redundant-err-return

Delete a redundant error return
This commit is contained in:
Brian Goff 2016-10-24 11:27:08 -07:00 committed by GitHub
commit 0ab13dda66
2 changed files with 7 additions and 14 deletions

View file

@ -380,12 +380,12 @@ func (daemon *Daemon) findAndAttachNetwork(container *container.Container, idOrN
} }
// updateContainerNetworkSettings update the network settings // updateContainerNetworkSettings update the network settings
func (daemon *Daemon) updateContainerNetworkSettings(container *container.Container, endpointsConfig map[string]*networktypes.EndpointSettings) error { func (daemon *Daemon) updateContainerNetworkSettings(container *container.Container, endpointsConfig map[string]*networktypes.EndpointSettings) {
var n libnetwork.Network var n libnetwork.Network
mode := container.HostConfig.NetworkMode mode := container.HostConfig.NetworkMode
if container.Config.NetworkDisabled || mode.IsContainer() { if container.Config.NetworkDisabled || mode.IsContainer() {
return nil return
} }
networkName := mode.NetworkName() networkName := mode.NetworkName()
@ -435,22 +435,20 @@ func (daemon *Daemon) updateContainerNetworkSettings(container *container.Contai
} }
if !mode.IsUserDefined() { if !mode.IsUserDefined() {
return nil return
} }
// Make sure to internally store the per network endpoint config by network name // Make sure to internally store the per network endpoint config by network name
if _, ok := container.NetworkSettings.Networks[networkName]; ok { if _, ok := container.NetworkSettings.Networks[networkName]; ok {
return nil return
} }
if n != nil { if n != nil {
if nwConfig, ok := container.NetworkSettings.Networks[n.ID()]; ok { if nwConfig, ok := container.NetworkSettings.Networks[n.ID()]; ok {
container.NetworkSettings.Networks[networkName] = nwConfig container.NetworkSettings.Networks[networkName] = nwConfig
delete(container.NetworkSettings.Networks, n.ID()) delete(container.NetworkSettings.Networks, n.ID())
return nil return
} }
} }
return nil
} }
func (daemon *Daemon) allocateNetwork(container *container.Container) error { func (daemon *Daemon) allocateNetwork(container *container.Container) error {
@ -471,10 +469,7 @@ func (daemon *Daemon) allocateNetwork(container *container.Container) error {
return nil return nil
} }
err := daemon.updateContainerNetworkSettings(container, nil) daemon.updateContainerNetworkSettings(container, nil)
if err != nil {
return err
}
updateSettings = true updateSettings = true
} }

View file

@ -135,9 +135,7 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig, managed bool) (
// backwards API compatibility. // backwards API compatibility.
container.HostConfig = runconfig.SetDefaultNetModeIfBlank(container.HostConfig) container.HostConfig = runconfig.SetDefaultNetModeIfBlank(container.HostConfig)
if err := daemon.updateContainerNetworkSettings(container, endpointsConfigs); err != nil { daemon.updateContainerNetworkSettings(container, endpointsConfigs)
return nil, err
}
if err := container.ToDisk(); err != nil { if err := container.ToDisk(); err != nil {
logrus.Errorf("Error saving new container to disk: %v", err) logrus.Errorf("Error saving new container to disk: %v", err)