mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fixed a few network UI issues in swarm-mode
* Detect name conflicts on network creation * Detect and prevent network connect/disconnect for managed containers Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
e904f58e19
commit
0ce5158a2a
2 changed files with 14 additions and 0 deletions
|
@ -81,6 +81,10 @@ func (n *networkRouter) postNetworkCreate(ctx context.Context, w http.ResponseWr
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, err := n.clusterProvider.GetNetwork(create.Name); err == nil {
|
||||||
|
return libnetwork.NetworkNameError(create.Name)
|
||||||
|
}
|
||||||
|
|
||||||
nw, err := n.backend.CreateNetwork(create)
|
nw, err := n.backend.CreateNetwork(create)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(libnetwork.ManagerRedirectError); !ok {
|
if _, ok := err.(libnetwork.ManagerRedirectError); !ok {
|
||||||
|
|
|
@ -292,6 +292,10 @@ func (daemon *Daemon) UpdateContainerServiceConfig(containerName string, service
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func errClusterNetworkConnect() error {
|
||||||
|
return fmt.Errorf("cannot connect or disconnect managed containers on a network")
|
||||||
|
}
|
||||||
|
|
||||||
// ConnectContainerToNetwork connects the given container to the given
|
// ConnectContainerToNetwork connects the given container to the given
|
||||||
// network. If either cannot be found, an err is returned. If the
|
// network. If either cannot be found, an err is returned. If the
|
||||||
// network cannot be set up, an err is returned.
|
// network cannot be set up, an err is returned.
|
||||||
|
@ -300,6 +304,9 @@ func (daemon *Daemon) ConnectContainerToNetwork(containerName, networkName strin
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if container.Managed {
|
||||||
|
return errClusterNetworkConnect()
|
||||||
|
}
|
||||||
return daemon.ConnectToNetwork(container, networkName, endpointConfig)
|
return daemon.ConnectToNetwork(container, networkName, endpointConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,6 +320,9 @@ func (daemon *Daemon) DisconnectContainerFromNetwork(containerName string, netwo
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if container.Managed {
|
||||||
|
return errClusterNetworkConnect()
|
||||||
|
}
|
||||||
return daemon.DisconnectFromNetwork(container, network, force)
|
return daemon.DisconnectFromNetwork(container, network, force)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue