Reducing the complexity in default gateway service handling

By removing the need to clear the default gateway during sbJoin and
sbLeave to account for other bridge network, the default-gw endpoint
will stay with the container, it will also help retain the container
property.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
Madhu Venugopal 2016-01-22 20:58:46 -08:00
parent 62b34aa361
commit 1419d96a01
3 changed files with 38 additions and 16 deletions

View file

@ -465,7 +465,7 @@ func (ep *endpoint) sbJoin(sbox Sandbox, options ...EndpointOption) error {
if sb.needDefaultGW() {
return sb.setupDefaultGW(ep)
}
return sb.clearDefaultGW()
return nil
}
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))
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 {

View file

@ -186,12 +186,6 @@ func (sb *sandbox) delete(force bool) error {
// Detach from all endpoints
retain := false
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.
if _, err := c.getNetworkFromStore(ep.getNetwork().ID()); err != nil {
retain = true

View file

@ -322,6 +322,42 @@ function test_overlay() {
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
for i in `seq ${start} ${end}`;
do