Check interface presence in new namespace

When an interface is moved to a new namespace, specially with OVS
internal ports, the interface first dissapears from any network
namespace and then is added again. ovs-vswitchd service detects
this interface change as reported in [1]. This delay is the cause
of the related bug, where some interfaces are not present when
the L3 agent needs to manipulate them.

[1]https://bugs.launchpad.net/neutron/+bug/1948832/comments/3

Closes-Bug: #1948832
Change-Id: I3af4d0afa784899689ccb595ce6ba64495431eb9
This commit is contained in:
Rodolfo Alonso Hernandez 2021-11-12 10:32:25 +00:00
parent 3ddc6dcbd9
commit ebc4766990
3 changed files with 15 additions and 1 deletions

View File

@ -445,6 +445,8 @@ class IpLinkCommand(IpDeviceCommandBase):
privileged.set_link_attribute(
self.name, self._parent.namespace, net_ns_fd=namespace)
self._parent.namespace = namespace
common_utils.wait_until_true(lambda: self.exists, timeout=5,
sleep=0.5)
def set_name(self, name):
privileged.set_link_attribute(

View File

@ -1149,3 +1149,14 @@ class ListIpRoutesTestCase(functional_base.BaseSudoTestCase):
return
self.fail('Not matching route, routes: %s' % routes)
class IpLinkCommandTestCase(IpLibTestFramework):
def test_set_netns(self):
device_name = ('int_' + uuidutils.generate_uuid())[
:constants.DEVICE_NAME_MAX_LEN]
device = ip_lib.IPDevice(device_name, kind='dummy')
device.link.create()
namespace = self.useFixture(net_helpers.NamespaceFixture())
device.link.set_netns(namespace.name)

View File

@ -618,8 +618,9 @@ class TestIpLinkCommand(TestIPCmdBase):
set_link_attribute.assert_called_once_with(
self.parent.name, self.parent.namespace, state='down')
@mock.patch.object(priv_lib, 'interface_exists', return_value=True)
@mock.patch.object(priv_lib, 'set_link_attribute')
def test_set_netns(self, set_link_attribute):
def test_set_netns(self, set_link_attribute, *args):
original_namespace = self.parent.namespace
self.link_cmd.set_netns('foo')
set_link_attribute.assert_called_once_with(