Browse code

Vendoring libnetwork

Signed-off-by: Madhu Venugopal <madhu@docker.com>

Madhu Venugopal authored on 2017/05/19 07:14:12
Showing 3 changed files
... ...
@@ -26,7 +26,7 @@ github.com/imdario/mergo 0.2.1
26 26
 golang.org/x/sync de49d9dcd27d4f764488181bea099dfe6179bcf0
27 27
 
28 28
 #get libnetwork packages
29
-github.com/docker/libnetwork b2bc1a68486ccf8ada503162d9f0df7d31bdd8fb
29
+github.com/docker/libnetwork 83e1e49475b88a9f1f8ba89a690a7d5de42e24b9
30 30
 github.com/docker/go-events 18b43f1bc85d9cdd42c05a6cd2d444c7a200a894
31 31
 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
32 32
 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
... ...
@@ -765,6 +765,10 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
765 765
 		return nil, types.ForbiddenErrorf("Cannot create a multi-host network from a worker node. Please create the network from a manager node.")
766 766
 	}
767 767
 
768
+	if network.scope == datastore.SwarmScope && c.isDistributedControl() {
769
+		return nil, types.ForbiddenErrorf("cannot create a swarm scoped network when swarm is not active")
770
+	}
771
+
768 772
 	// Make sure we have a driver available for this network type
769 773
 	// before we allocate anything.
770 774
 	if _, err := network.driver(true); err != nil {
... ...
@@ -356,10 +356,10 @@ func (n *network) validateConfiguration() error {
356 356
 	if n.configOnly {
357 357
 		// Only supports network specific configurations.
358 358
 		// Network operator configurations are not supported.
359
-		if n.ingress || n.internal || n.attachable {
359
+		if n.ingress || n.internal || n.attachable || n.scope != "" {
360 360
 			return types.ForbiddenErrorf("configuration network can only contain network " +
361 361
 				"specific fields. Network operator fields like " +
362
-				"[ ingress | internal | attachable ] are not supported.")
362
+				"[ ingress | internal | attachable | scope ] are not supported.")
363 363
 		}
364 364
 	}
365 365
 	if n.configFrom != "" {
... ...
@@ -904,17 +904,14 @@ func (n *network) driver(load bool) (driverapi.Driver, error) {
904 904
 		return nil, err
905 905
 	}
906 906
 
907
-	c := n.getController()
908
-	isAgent := c.isAgent()
909 907
 	n.Lock()
910 908
 	// If load is not required, driver, cap and err may all be nil
911 909
 	if n.scope == "" && cap != nil {
912 910
 		n.scope = cap.DataScope
913 911
 	}
914
-	if isAgent && n.dynamic {
915
-		// If we are running in agent mode and the network
916
-		// is dynamic, then the networks are swarm scoped
917
-		// regardless of the backing driver.
912
+	if n.dynamic {
913
+		// If the network is dynamic, then it is swarm
914
+		// scoped regardless of the backing driver.
918 915
 		n.scope = datastore.SwarmScope
919 916
 	}
920 917
 	n.Unlock()