Remove duplication checking for the existence of endpoint to speed up container starting
| ... | ... |
@@ -771,22 +771,13 @@ func (daemon *Daemon) connectToNetwork(container *container.Container, idOrName |
| 771 | 771 |
container.NetworkSettings.Networks[n.Name()] = endpointConfig |
| 772 | 772 |
} |
| 773 | 773 |
|
| 774 |
- ep, err := container.GetEndpointInNetwork(n) |
|
| 775 |
- if err == nil {
|
|
| 776 |
- return fmt.Errorf("Conflict. A container with name %q is already connected to network %s.", strings.TrimPrefix(container.Name, "/"), idOrName)
|
|
| 777 |
- } |
|
| 778 |
- |
|
| 779 |
- if _, ok := err.(libnetwork.ErrNoSuchEndpoint); !ok {
|
|
| 780 |
- return err |
|
| 781 |
- } |
|
| 782 |
- |
|
| 783 | 774 |
createOptions, err := container.BuildCreateEndpointOptions(n) |
| 784 | 775 |
if err != nil {
|
| 785 | 776 |
return err |
| 786 | 777 |
} |
| 787 | 778 |
|
| 788 | 779 |
endpointName := strings.TrimPrefix(container.Name, "/") |
| 789 |
- ep, err = n.CreateEndpoint(endpointName, createOptions...) |
|
| 780 |
+ ep, err := n.CreateEndpoint(endpointName, createOptions...) |
|
| 790 | 781 |
if err != nil {
|
| 791 | 782 |
return err |
| 792 | 783 |
} |