Browse Source

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
tags/11.0.0.0b2
Ihar Hrachyshka 2 years ago
parent
commit
91c15edf54

+ 2
- 1
neutron/agent/l3/dvr_edge_router.py View File

@@ -251,7 +251,8 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
251 251
             return
252 252
 
253 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 256
             if (d.name.startswith(router.EXTERNAL_DEV_PREFIX) and
256 257
                     d.name != interface_name):
257 258
                 LOG.debug('Deleting stale external router device: %s', d.name)

+ 2
- 1
neutron/agent/l3/dvr_fip_ns.py View File

@@ -207,7 +207,8 @@ class FipNamespace(namespaces.Namespace):
207 207
     @namespaces.check_ns_existence
208 208
     def _delete(self):
209 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 212
             if d.name.startswith(FIP_2_ROUTER_DEV_PREFIX):
212 213
                 # internal link between IRs and FIP NS
213 214
                 ip_wrapper.del_veth(d.name)

+ 2
- 1
neutron/agent/l3/dvr_snat_ns.py View File

@@ -41,7 +41,8 @@ class SnatNamespace(namespaces.Namespace):
41 41
     @namespaces.check_ns_existence
42 42
     def delete(self):
43 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 46
             if d.name.startswith(constants.SNAT_INT_DEV_PREFIX):
46 47
                 LOG.debug('Unplugging DVR device %s', d.name)
47 48
                 self.driver.unplug(d.name, namespace=self.name,

+ 2
- 1
neutron/agent/l3/namespaces.py View File

@@ -123,7 +123,8 @@ class RouterNamespace(Namespace):
123 123
     @check_ns_existence
124 124
     def delete(self):
125 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 128
             if d.name.startswith(INTERNAL_DEV_PREFIX):
128 129
                 # device is on default bridge
129 130
                 self.driver.unplug(d.name, namespace=self.name,

+ 2
- 1
neutron/agent/l3/router_info.py View File

@@ -468,7 +468,8 @@ class RouterInfo(object):
468 468
 
469 469
     def _get_existing_devices(self):
470 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 473
         return [ip_dev.name for ip_dev in ip_devs]
473 474
 
474 475
     @staticmethod

+ 2
- 1
neutron/agent/linux/dhcp.py View File

@@ -1337,7 +1337,8 @@ class DeviceManager(object):
1337 1337
         ns_ip = ip_lib.IPWrapper(namespace=network.namespace)
1338 1338
         if not ns_ip.netns.exists(network.namespace):
1339 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 1342
             # delete all devices except current active DHCP port device
1342 1343
             if d.name != skip_dev_name:
1343 1344
                 LOG.debug("Found stale device %s, deleting", d.name)

+ 2
- 1
neutron/cmd/netns_cleanup.py View File

@@ -248,7 +248,8 @@ def destroy_namespace(conf, namespace, force=False):
248 248
                     # the error and continue with the cleanup
249 249
                     LOG.error(_LE('Not all processes were killed in %s'),
250 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 253
                     unplug_device(conf, device)
253 254
 
254 255
         ip.garbage_collect_namespace()

+ 2
- 1
neutron/tests/unit/cmd/test_netns_cleanup.py View File

@@ -336,7 +336,8 @@ class TestNetnsCleanup(base.BaseTestCase):
336 336
                             expected.extend([
337 337
                                 mock.call().netns.exists(ns),
338 338
                                 mock.call().get_devices(
339
-                                    exclude_loopback=True)])
339
+                                    exclude_loopback=True,
340
+                                    exclude_gre_devices=True)])
340 341
                             self.assertTrue(kill_dhcp.called)
341 342
                             unplug.assert_has_calls(
342 343
                                 [mock.call(conf, d) for d in

Loading…
Cancel
Save