Преглед на файлове

Merge pull request #893 from mavenugo/gwservice

Reducing the complexity in default gateway service handling
aboch преди 9 години
родител
ревизия
7cefc36f02
променени са 3 файла, в които са добавени 38 реда и са изтрити 16 реда
  1. 2 10
      libnetwork/endpoint.go
  2. 0 6
      libnetwork/sandbox.go
  3. 36 0
      libnetwork/test/integration/dnet/helpers.bash

+ 2 - 10
libnetwork/endpoint.go

@@ -465,7 +465,7 @@ func (ep *endpoint) sbJoin(sbox Sandbox, options ...EndpointOption) error {
 	if sb.needDefaultGW() {
 	if sb.needDefaultGW() {
 		return sb.setupDefaultGW(ep)
 		return sb.setupDefaultGW(ep)
 	}
 	}
-	return sb.clearDefaultGW()
+	return nil
 }
 }
 
 
 func (ep *endpoint) rename(name string) error {
 func (ep *endpoint) rename(name string) error {
@@ -597,15 +597,7 @@ func (ep *endpoint) sbLeave(sbox Sandbox, force bool, options ...EndpointOption)
 	}
 	}
 
 
 	sb.deleteHostsEntries(n.getSvcRecords(ep))
 	sb.deleteHostsEntries(n.getSvcRecords(ep))
-
-	if !sb.inDelete && sb.needDefaultGW() {
-		ep := sb.getEPwithoutGateway()
-		if ep == nil {
-			return fmt.Errorf("endpoint without GW expected, but not found")
-		}
-		return sb.setupDefaultGW(ep)
-	}
-	return sb.clearDefaultGW()
+	return nil
 }
 }
 
 
 func (n *network) validateForceDelete(locator string) error {
 func (n *network) validateForceDelete(locator string) error {

+ 0 - 6
libnetwork/sandbox.go

@@ -186,12 +186,6 @@ func (sb *sandbox) delete(force bool) error {
 	// Detach from all endpoints
 	// Detach from all endpoints
 	retain := false
 	retain := false
 	for _, ep := range sb.getConnectedEndpoints() {
 	for _, ep := range sb.getConnectedEndpoints() {
-		// endpoint in the Gateway network will be cleaned up
-		// when when sandbox no longer needs external connectivity
-		if ep.endpointInGWNetwork() {
-			continue
-		}
-
 		// Retain the sanbdox if we can't obtain the network from store.
 		// Retain the sanbdox if we can't obtain the network from store.
 		if _, err := c.getNetworkFromStore(ep.getNetwork().ID()); err != nil {
 		if _, err := c.getNetworkFromStore(ep.getNetwork().ID()); err != nil {
 			retain = true
 			retain = true

+ 36 - 0
libnetwork/test/integration/dnet/helpers.bash

@@ -322,6 +322,42 @@ function test_overlay() {
 	done
 	done
     done
     done
 
 
+    # Setup bridge network and connect containers ot it
+    if [ -z "${2}" -o "${2}" != "skip_add" ]; then
+        if [ -z "${2}" -o "${2}" != "internal" ]; then
+	    dnet_cmd $(inst_id2port 1) network create -d bridge br1
+	    dnet_cmd $(inst_id2port 1) network create -d bridge br2
+	    net_connect ${start} container_${start} br1
+	    net_connect ${start} container_${start} br2
+
+            # Make sure external connectivity works
+	    runc $(dnet_container_name ${start} $dnet_suffix) $(get_sbox_id ${start} container_${start}) \
+	        "ping -c 1 www.google.com"
+	    net_disconnect ${start} container_${start} br1
+	    net_disconnect ${start} container_${start} br2
+
+            # Make sure external connectivity works
+	    runc $(dnet_container_name ${start} $dnet_suffix) $(get_sbox_id ${start} container_${start}) \
+	        "ping -c 1 www.google.com"
+	    dnet_cmd $(inst_id2port 1) network rm br1
+	    dnet_cmd $(inst_id2port 1) network rm br2
+
+            # Disconnect from overlay network
+            net_disconnect ${start} container_${start} multihost
+
+            # Make sure external connectivity works
+            runc $(dnet_container_name ${start} $dnet_suffix) $(get_sbox_id ${start} container_${start}) \
+                "ping -c 1 www.google.com"
+
+            # Connect to overlay network again
+            net_connect ${start} container_${start} multihost
+
+            # Make sure external connectivity still works
+            runc $(dnet_container_name ${start} $dnet_suffix) $(get_sbox_id ${start} container_${start}) \
+                "ping -c 1 www.google.com"
+	fi
+    fi
+
     # Teardown the container connections and the network
     # Teardown the container connections and the network
     for i in `seq ${start} ${end}`;
     for i in `seq ${start} ${end}`;
     do
     do