Просмотр исходного кода

daemon: buildCreateEndpointOptions: skip getPortMapInfo() if not needed

`getPortMapInfo` does many things; it creates a copy of all the sandbox
endpoints, gets the driver, endpoints, and network from store, and creates
port-bindings for all exposed and mapped ports.

We should look if we can create a more minimal implementation for this
purpose, but in the meantime, let's prevent it being called if we don't
need it by making it the second condition in the check.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 2 лет назад
Родитель
Сommit
6ce92aa523
1 измененных файлов с 4 добавлено и 3 удалено
  1. 4 3
      daemon/network.go

+ 4 - 3
daemon/network.go

@@ -893,9 +893,10 @@ func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, e
 		}
 	}
 
-	// Port-mapping rules belong to the container & applicable only to non-internal networks
-	portmaps := getPortMapInfo(sb)
-	if n.Info().Internal() || len(portmaps) > 0 {
+	// Port-mapping rules belong to the container & applicable only to non-internal networks.
+	//
+	// TODO(thaJeztah): Look if we can provide a more minimal function for getPortMapInfo, as it does a lot, and we only need the "length".
+	if n.Info().Internal() || len(getPortMapInfo(sb)) > 0 {
 		return createOptions, nil
 	}