Merge "Reset device namespace when adding to the namespace fails" into stable/wallaby
This commit is contained in:
@@ -377,6 +377,11 @@ class OVSInterfaceDriver(LinuxInterfaceDriver):
|
||||
LOG.warning("Failed to set interface %s into namespace %s. "
|
||||
"Interface not found, attempt: %s, retrying.",
|
||||
device, namespace, i + 1)
|
||||
# NOTE(slaweq) In such case it's required to reset device's
|
||||
# namespace as it was already set to the "namespace"
|
||||
# and after retry neutron will look for it in that namespace
|
||||
# which is wrong
|
||||
device.namespace = None
|
||||
time.sleep(1)
|
||||
except utils.WaitTimeout:
|
||||
# NOTE(slaweq): if the exception was WaitTimeout then it means
|
||||
|
||||
@@ -529,6 +529,20 @@ class TestOVSInterfaceDriver(TestBase):
|
||||
ovs_br.assert_has_calls([mock.call('br-int'),
|
||||
mock.call().delete_port('tap0')])
|
||||
|
||||
def test__add_device_to_namespace_retries(self):
|
||||
ovs = interface.OVSInterfaceDriver(self.conf)
|
||||
namespace_obj = self.ip.return_value.ensure_namespace.return_value
|
||||
self.ip.ensure_namespace.return_value = namespace_obj
|
||||
namespace_obj.add_device_to_namespace.side_effect = (
|
||||
ip_lib.NetworkInterfaceNotFound)
|
||||
device = mock.MagicMock()
|
||||
self.assertRaises(
|
||||
ip_lib.NetworkInterfaceNotFound,
|
||||
ovs._add_device_to_namespace,
|
||||
self.ip, device, "test-ns")
|
||||
self.assertEqual(10, namespace_obj.add_device_to_namespace.call_count)
|
||||
self.assertIsNone(device.namespace)
|
||||
|
||||
|
||||
class TestOVSInterfaceDriverWithVeth(TestOVSInterfaceDriver):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user