From f62d4ceba66ef6b979be8f45d0acf260bea27a13 Mon Sep 17 00:00:00 2001 From: Lei Jitang Date: Mon, 11 Jan 2016 14:45:43 +0800 Subject: [PATCH] Remove duplication checking for the existence of endpoint CreateEndpoint will check if the endpoint exist or not, so there is no need to check before call CreatEndpoint in connectToNetwork since checking the existence of the endpoint could take much time especially if we use external K-V store, this would slow down the staring of container. Signed-off-by: Lei Jitang --- daemon/container_operations_unix.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/daemon/container_operations_unix.go b/daemon/container_operations_unix.go index 9840fa2b0f..73077cf6bb 100644 --- a/daemon/container_operations_unix.go +++ b/daemon/container_operations_unix.go @@ -758,22 +758,13 @@ func (daemon *Daemon) connectToNetwork(container *container.Container, idOrName container.NetworkSettings.Networks[n.Name()] = endpointConfig } - ep, err := container.GetEndpointInNetwork(n) - if err == nil { - return fmt.Errorf("Conflict. A container with name %q is already connected to network %s.", strings.TrimPrefix(container.Name, "/"), idOrName) - } - - if _, ok := err.(libnetwork.ErrNoSuchEndpoint); !ok { - return err - } - createOptions, err := container.BuildCreateEndpointOptions(n) if err != nil { return err } endpointName := strings.TrimPrefix(container.Name, "/") - ep, err = n.CreateEndpoint(endpointName, createOptions...) + ep, err := n.CreateEndpoint(endpointName, createOptions...) if err != nil { return err }