From de0918cea3fa3c107d4cc08137c04573274716f8 Mon Sep 17 00:00:00 2001 From: elajkat Date: Tue, 10 Jan 2023 10:51:17 +0100 Subject: [PATCH] Add debug logs to OVSInterfaceDriver.plug_new DVR lifecycle functional tests fail frequently with exceptions like this: "Network interface * not found in namespace *" The reproduction locally is hard if possible, so by adding extra log messages I hope we can have more clue where to find the possible root cause of this issue. Change-Id: I2c6acf3c29f3d1e7574240376f7bcb46c98579c6 Related-Bug: #1995031 --- neutron/agent/linux/interface.py | 10 ++++++++++ neutron/tests/unit/agent/linux/test_interface.py | 1 + 2 files changed, 11 insertions(+) diff --git a/neutron/agent/linux/interface.py b/neutron/agent/linux/interface.py index 870329174a2..914d004cf7c 100644 --- a/neutron/agent/linux/interface.py +++ b/neutron/agent/linux/interface.py @@ -401,6 +401,9 @@ class OVSInterfaceDriver(LinuxInterfaceDriver): root_dev.disable_ipv6() else: ns_dev = ip.device(device_name) + if not ns_dev: + LOG.warning("Device %s is not ready in namespace %s!", + device_name, namespace) internal = not self.conf.ovs_use_veth self._ovs_add_port(bridge, tap_name, port_id, mac_address, @@ -429,6 +432,13 @@ class OVSInterfaceDriver(LinuxInterfaceDriver): with excutils.save_and_reraise_exception(): ovs = ovs_lib.OVSBridge(bridge) ovs.delete_port(tap_name) + except Exception as exc: + LOG.warning("Failed to plug interface %s to bridge %s in " + "namespace %s due to unknown reason: %s", + device_name, bridge, namespace, str(exc)) + with excutils.save_and_reraise_exception(): + ovs = ovs_lib.OVSBridge(bridge) + ovs.delete_port(tap_name) # NOTE(ihrachys): the order here is significant: we must set MTU after # the device is moved into a namespace, otherwise OVS bridge does not diff --git a/neutron/tests/unit/agent/linux/test_interface.py b/neutron/tests/unit/agent/linux/test_interface.py index 9b3b5ca13eb..6869db9aeb5 100644 --- a/neutron/tests/unit/agent/linux/test_interface.py +++ b/neutron/tests/unit/agent/linux/test_interface.py @@ -461,6 +461,7 @@ class TestOVSInterfaceDriver(TestBase): expected = [ mock.call(), mock.call().device('tap0'), + mock.ANY, mock.call().device().link.set_address('aa:bb:cc:dd:ee:ff'), mock.call().device().link.set_address('aa:bb:cc:dd:ee:ff')] if namespace: