summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIhar Hrachyshka <ihrachys@redhat.com>2017-04-07 13:10:06 -0700
committerIhar Hrachyshka <ihrachys@redhat.com>2017-04-13 15:02:35 -0700
commit91c15edf54c07da77ecf4fc335b0ba3951ff1f90 (patch)
treeeb934330a99387eb2c86e12342152764a7a92c68
parent4e3032825f1f15a4c273bb0ce9b791be20f780ab (diff)
Ignore gre devices in namespaces when cleaning up devices
Agents and netns_cleanup tool attempt to clean up devices from namespaces before destroying namespaces, but they should skip doing it for gre devices that are automatic and show up depending on kernel modules loaded. Change-Id: Ie95890ed92ac73ec8e2d118a9727b9e1624a5178 Related-Bug: #1604115
Notes
Notes (review): Code-Review+2: Kevin Benton <kevin@benton.pub> Code-Review+2: Brian Haley <haleyb.dev@gmail.com> Workflow+1: Brian Haley <haleyb.dev@gmail.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Mon, 17 Apr 2017 18:15:48 +0000 Reviewed-on: https://review.openstack.org/454872 Project: openstack/neutron Branch: refs/heads/master
-rw-r--r--neutron/agent/l3/dvr_edge_router.py3
-rw-r--r--neutron/agent/l3/dvr_fip_ns.py3
-rw-r--r--neutron/agent/l3/dvr_snat_ns.py3
-rw-r--r--neutron/agent/l3/namespaces.py3
-rw-r--r--neutron/agent/l3/router_info.py3
-rw-r--r--neutron/agent/linux/dhcp.py3
-rw-r--r--neutron/cmd/netns_cleanup.py3
-rw-r--r--neutron/tests/unit/cmd/test_netns_cleanup.py3
8 files changed, 16 insertions, 8 deletions
diff --git a/neutron/agent/l3/dvr_edge_router.py b/neutron/agent/l3/dvr_edge_router.py
index c4416d7..11f31bc 100644
--- a/neutron/agent/l3/dvr_edge_router.py
+++ b/neutron/agent/l3/dvr_edge_router.py
@@ -251,7 +251,8 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
251 return 251 return
252 252
253 ns_ip = ip_lib.IPWrapper(namespace=self.snat_namespace.name) 253 ns_ip = ip_lib.IPWrapper(namespace=self.snat_namespace.name)
254 for d in ns_ip.get_devices(exclude_loopback=True): 254 for d in ns_ip.get_devices(exclude_loopback=True,
255 exclude_gre_devices=True):
255 if (d.name.startswith(router.EXTERNAL_DEV_PREFIX) and 256 if (d.name.startswith(router.EXTERNAL_DEV_PREFIX) and
256 d.name != interface_name): 257 d.name != interface_name):
257 LOG.debug('Deleting stale external router device: %s', d.name) 258 LOG.debug('Deleting stale external router device: %s', d.name)
diff --git a/neutron/agent/l3/dvr_fip_ns.py b/neutron/agent/l3/dvr_fip_ns.py
index 80729de..09c1281 100644
--- a/neutron/agent/l3/dvr_fip_ns.py
+++ b/neutron/agent/l3/dvr_fip_ns.py
@@ -207,7 +207,8 @@ class FipNamespace(namespaces.Namespace):
207 @namespaces.check_ns_existence 207 @namespaces.check_ns_existence
208 def _delete(self): 208 def _delete(self):
209 ip_wrapper = ip_lib.IPWrapper(namespace=self.name) 209 ip_wrapper = ip_lib.IPWrapper(namespace=self.name)
210 for d in ip_wrapper.get_devices(exclude_loopback=True): 210 for d in ip_wrapper.get_devices(exclude_loopback=True,
211 exclude_gre_devices=True):
211 if d.name.startswith(FIP_2_ROUTER_DEV_PREFIX): 212 if d.name.startswith(FIP_2_ROUTER_DEV_PREFIX):
212 # internal link between IRs and FIP NS 213 # internal link between IRs and FIP NS
213 ip_wrapper.del_veth(d.name) 214 ip_wrapper.del_veth(d.name)
diff --git a/neutron/agent/l3/dvr_snat_ns.py b/neutron/agent/l3/dvr_snat_ns.py
index f22e717..085dc5c 100644
--- a/neutron/agent/l3/dvr_snat_ns.py
+++ b/neutron/agent/l3/dvr_snat_ns.py
@@ -41,7 +41,8 @@ class SnatNamespace(namespaces.Namespace):
41 @namespaces.check_ns_existence 41 @namespaces.check_ns_existence
42 def delete(self): 42 def delete(self):
43 ns_ip = ip_lib.IPWrapper(namespace=self.name) 43 ns_ip = ip_lib.IPWrapper(namespace=self.name)
44 for d in ns_ip.get_devices(exclude_loopback=True): 44 for d in ns_ip.get_devices(exclude_loopback=True,
45 exclude_gre_devices=True):
45 if d.name.startswith(constants.SNAT_INT_DEV_PREFIX): 46 if d.name.startswith(constants.SNAT_INT_DEV_PREFIX):
46 LOG.debug('Unplugging DVR device %s', d.name) 47 LOG.debug('Unplugging DVR device %s', d.name)
47 self.driver.unplug(d.name, namespace=self.name, 48 self.driver.unplug(d.name, namespace=self.name,
diff --git a/neutron/agent/l3/namespaces.py b/neutron/agent/l3/namespaces.py
index e70d7bb..f65c706 100644
--- a/neutron/agent/l3/namespaces.py
+++ b/neutron/agent/l3/namespaces.py
@@ -123,7 +123,8 @@ class RouterNamespace(Namespace):
123 @check_ns_existence 123 @check_ns_existence
124 def delete(self): 124 def delete(self):
125 ns_ip = ip_lib.IPWrapper(namespace=self.name) 125 ns_ip = ip_lib.IPWrapper(namespace=self.name)
126 for d in ns_ip.get_devices(exclude_loopback=True): 126 for d in ns_ip.get_devices(exclude_loopback=True,
127 exclude_gre_devices=True):
127 if d.name.startswith(INTERNAL_DEV_PREFIX): 128 if d.name.startswith(INTERNAL_DEV_PREFIX):
128 # device is on default bridge 129 # device is on default bridge
129 self.driver.unplug(d.name, namespace=self.name, 130 self.driver.unplug(d.name, namespace=self.name,
diff --git a/neutron/agent/l3/router_info.py b/neutron/agent/l3/router_info.py
index e401df4..459a882 100644
--- a/neutron/agent/l3/router_info.py
+++ b/neutron/agent/l3/router_info.py
@@ -468,7 +468,8 @@ class RouterInfo(object):
468 468
469 def _get_existing_devices(self): 469 def _get_existing_devices(self):
470 ip_wrapper = ip_lib.IPWrapper(namespace=self.ns_name) 470 ip_wrapper = ip_lib.IPWrapper(namespace=self.ns_name)
471 ip_devs = ip_wrapper.get_devices(exclude_loopback=True) 471 ip_devs = ip_wrapper.get_devices(exclude_loopback=True,
472 exclude_gre_devices=True)
472 return [ip_dev.name for ip_dev in ip_devs] 473 return [ip_dev.name for ip_dev in ip_devs]
473 474
474 @staticmethod 475 @staticmethod
diff --git a/neutron/agent/linux/dhcp.py b/neutron/agent/linux/dhcp.py
index eb40ff9..810f01f 100644
--- a/neutron/agent/linux/dhcp.py
+++ b/neutron/agent/linux/dhcp.py
@@ -1337,7 +1337,8 @@ class DeviceManager(object):
1337 ns_ip = ip_lib.IPWrapper(namespace=network.namespace) 1337 ns_ip = ip_lib.IPWrapper(namespace=network.namespace)
1338 if not ns_ip.netns.exists(network.namespace): 1338 if not ns_ip.netns.exists(network.namespace):
1339 return 1339 return
1340 for d in ns_ip.get_devices(exclude_loopback=True): 1340 for d in ns_ip.get_devices(exclude_loopback=True,
1341 exclude_gre_devices=True):
1341 # delete all devices except current active DHCP port device 1342 # delete all devices except current active DHCP port device
1342 if d.name != skip_dev_name: 1343 if d.name != skip_dev_name:
1343 LOG.debug("Found stale device %s, deleting", d.name) 1344 LOG.debug("Found stale device %s, deleting", d.name)
diff --git a/neutron/cmd/netns_cleanup.py b/neutron/cmd/netns_cleanup.py
index d6e660d..3729560 100644
--- a/neutron/cmd/netns_cleanup.py
+++ b/neutron/cmd/netns_cleanup.py
@@ -248,7 +248,8 @@ def destroy_namespace(conf, namespace, force=False):
248 # the error and continue with the cleanup 248 # the error and continue with the cleanup
249 LOG.error(_LE('Not all processes were killed in %s'), 249 LOG.error(_LE('Not all processes were killed in %s'),
250 namespace) 250 namespace)
251 for device in ip.get_devices(exclude_loopback=True): 251 for device in ip.get_devices(exclude_loopback=True,
252 exclude_gre_devices=True):
252 unplug_device(conf, device) 253 unplug_device(conf, device)
253 254
254 ip.garbage_collect_namespace() 255 ip.garbage_collect_namespace()
diff --git a/neutron/tests/unit/cmd/test_netns_cleanup.py b/neutron/tests/unit/cmd/test_netns_cleanup.py
index 56af8ea..cbf030d 100644
--- a/neutron/tests/unit/cmd/test_netns_cleanup.py
+++ b/neutron/tests/unit/cmd/test_netns_cleanup.py
@@ -336,7 +336,8 @@ class TestNetnsCleanup(base.BaseTestCase):
336 expected.extend([ 336 expected.extend([
337 mock.call().netns.exists(ns), 337 mock.call().netns.exists(ns),
338 mock.call().get_devices( 338 mock.call().get_devices(
339 exclude_loopback=True)]) 339 exclude_loopback=True,
340 exclude_gre_devices=True)])
340 self.assertTrue(kill_dhcp.called) 341 self.assertTrue(kill_dhcp.called)
341 unplug.assert_has_calls( 342 unplug.assert_has_calls(
342 [mock.call(conf, d) for d in 343 [mock.call(conf, d) for d in