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
(cherry picked from commit 91c15edf54
)
This commit is contained in:
parent
633b452e28
commit
b744172fb8
@ -251,7 +251,8 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
|
||||
return
|
||||
|
||||
ns_ip = ip_lib.IPWrapper(namespace=self.snat_namespace.name)
|
||||
for d in ns_ip.get_devices(exclude_loopback=True):
|
||||
for d in ns_ip.get_devices(exclude_loopback=True,
|
||||
exclude_gre_devices=True):
|
||||
if (d.name.startswith(router.EXTERNAL_DEV_PREFIX) and
|
||||
d.name != interface_name):
|
||||
LOG.debug('Deleting stale external router device: %s', d.name)
|
||||
|
@ -207,7 +207,8 @@ class FipNamespace(namespaces.Namespace):
|
||||
@namespaces.check_ns_existence
|
||||
def _delete(self):
|
||||
ip_wrapper = ip_lib.IPWrapper(namespace=self.name)
|
||||
for d in ip_wrapper.get_devices(exclude_loopback=True):
|
||||
for d in ip_wrapper.get_devices(exclude_loopback=True,
|
||||
exclude_gre_devices=True):
|
||||
if d.name.startswith(FIP_2_ROUTER_DEV_PREFIX):
|
||||
# internal link between IRs and FIP NS
|
||||
ip_wrapper.del_veth(d.name)
|
||||
|
@ -41,7 +41,8 @@ class SnatNamespace(namespaces.Namespace):
|
||||
@namespaces.check_ns_existence
|
||||
def delete(self):
|
||||
ns_ip = ip_lib.IPWrapper(namespace=self.name)
|
||||
for d in ns_ip.get_devices(exclude_loopback=True):
|
||||
for d in ns_ip.get_devices(exclude_loopback=True,
|
||||
exclude_gre_devices=True):
|
||||
if d.name.startswith(constants.SNAT_INT_DEV_PREFIX):
|
||||
LOG.debug('Unplugging DVR device %s', d.name)
|
||||
self.driver.unplug(d.name, namespace=self.name,
|
||||
|
@ -123,7 +123,8 @@ class RouterNamespace(Namespace):
|
||||
@check_ns_existence
|
||||
def delete(self):
|
||||
ns_ip = ip_lib.IPWrapper(namespace=self.name)
|
||||
for d in ns_ip.get_devices(exclude_loopback=True):
|
||||
for d in ns_ip.get_devices(exclude_loopback=True,
|
||||
exclude_gre_devices=True):
|
||||
if d.name.startswith(INTERNAL_DEV_PREFIX):
|
||||
# device is on default bridge
|
||||
self.driver.unplug(d.name, namespace=self.name,
|
||||
|
@ -465,7 +465,8 @@ class RouterInfo(object):
|
||||
|
||||
def _get_existing_devices(self):
|
||||
ip_wrapper = ip_lib.IPWrapper(namespace=self.ns_name)
|
||||
ip_devs = ip_wrapper.get_devices(exclude_loopback=True)
|
||||
ip_devs = ip_wrapper.get_devices(exclude_loopback=True,
|
||||
exclude_gre_devices=True)
|
||||
return [ip_dev.name for ip_dev in ip_devs]
|
||||
|
||||
@staticmethod
|
||||
|
@ -1337,7 +1337,8 @@ class DeviceManager(object):
|
||||
ns_ip = ip_lib.IPWrapper(namespace=network.namespace)
|
||||
if not ns_ip.netns.exists(network.namespace):
|
||||
return
|
||||
for d in ns_ip.get_devices(exclude_loopback=True):
|
||||
for d in ns_ip.get_devices(exclude_loopback=True,
|
||||
exclude_gre_devices=True):
|
||||
# delete all devices except current active DHCP port device
|
||||
if d.name != skip_dev_name:
|
||||
LOG.debug("Found stale device %s, deleting", d.name)
|
||||
|
@ -248,7 +248,8 @@ def destroy_namespace(conf, namespace, force=False):
|
||||
# the error and continue with the cleanup
|
||||
LOG.error(_LE('Not all processes were killed in %s'),
|
||||
namespace)
|
||||
for device in ip.get_devices(exclude_loopback=True):
|
||||
for device in ip.get_devices(exclude_loopback=True,
|
||||
exclude_gre_devices=True):
|
||||
unplug_device(conf, device)
|
||||
|
||||
ip.garbage_collect_namespace()
|
||||
|
@ -336,7 +336,8 @@ class TestNetnsCleanup(base.BaseTestCase):
|
||||
expected.extend([
|
||||
mock.call().netns.exists(ns),
|
||||
mock.call().get_devices(
|
||||
exclude_loopback=True)])
|
||||
exclude_loopback=True,
|
||||
exclude_gre_devices=True)])
|
||||
self.assertTrue(kill_dhcp.called)
|
||||
unplug.assert_has_calls(
|
||||
[mock.call(conf, d) for d in
|
||||
|
Loading…
Reference in New Issue
Block a user