[Bug 1948466] Re: [OVN] Mech driver fails to delete DHCP options during subnet deletion
nikhil kshirsagar
1948466 at bugs.launchpad.net
Tue Sep 5 07:41:37 UTC 2023
I've tested the proposed package on focal. Testing details are uploaded.
Without the fix I do see the issue mentioned in this LP, with an empty
directory hardcoded, like so,
def _remove_subnet_dhcp_options(self, subnet_id, txn):
dhcp_options = self._nb_idl.get_subnet_dhcp_options(
subnet_id, with_ports=True)
dhcp_options['subnet'] = {} <--
print(dhcp_options['subnet'])
if dhcp_options['subnet'] is not None:
txn.add(self._nb_idl.delete_dhcp_options(
dhcp_options['subnet']['uuid']))
root at juju-3b1260-fixtestnew-6:/usr/lib/python3/dist-packages# python3 -m unittest neutron.tests.unit.plugins.ml2.drivers.ovn.mech_driver.test_mech_driver.TestOVNMechanismDriver.test_remove_subnet_dhcp_options_in_ovn_ipv4
/usr/lib/python3/dist-packages/neutron_lib/worker.py:68: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
self._parent_proctitle = setproctitle.getproctitle()
{}
E
======================================================================
ERROR: test_remove_subnet_dhcp_options_in_ovn_ipv4 (neutron.tests.unit.plugins.ml2.drivers.ovn.mech_driver.test_mech_driver.TestOVNMechanismDriver)
neutron.tests.unit.plugins.ml2.drivers.ovn.mech_driver.test_mech_driver.TestOVNMechanismDriver.test_remove_subnet_dhcp_options_in_ovn_ipv4
----------------------------------------------------------------------
testtools.testresult.real._StringException: Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/neutron/tests/base.py", line 182, in func
return f(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py", line 1368, in test_remove_subnet_dhcp_options_in_ovn_ipv4
self._test_remove_subnet_dhcp_options_in_ovn(4)
File "/usr/lib/python3/dist-packages/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py", line 1356, in _test_remove_subnet_dhcp_options_in_ovn
self.mech_driver._ovn_client._remove_subnet_dhcp_options(
File "/usr/lib/python3/dist-packages/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py", line 1893, in _remove_subnet_dhcp_options
dhcp_options['subnet']['uuid']))
KeyError: 'uuid'
----------------------------------------------------------------------
Ran 1 test in 3.235s
With the fix, the KeyError is resolved, the unit test fails though, and I am assuming this failure is expected.
def _remove_subnet_dhcp_options(self, subnet_id, txn):
dhcp_options = self._nb_idl.get_subnet_dhcp_options(
subnet_id, with_ports=True)
dhcp_options['subnet'] = {} <--
print(dhcp_options['subnet'])
if dhcp_options['subnet']:
txn.add(self._nb_idl.delete_dhcp_options(
dhcp_options['subnet']['uuid']))
root at juju-3b1260-fixtestnew-6:/usr/lib/python3/dist-packages# python3 -m unittest neutron.tests.unit.plugins.ml2.drivers.ovn.mech_driver.test_mech_driver.TestOVNMechanismDriver.test_remove_subnet_dhcp_options_in_ovn_ipv4
/usr/lib/python3/dist-packages/neutron_lib/worker.py:68: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
self._parent_proctitle = setproctitle.getproctitle()
{}
F
======================================================================
FAIL: test_remove_subnet_dhcp_options_in_ovn_ipv4 (neutron.tests.unit.plugins.ml2.drivers.ovn.mech_driver.test_mech_driver.TestOVNMechanismDriver)
neutron.tests.unit.plugins.ml2.drivers.ovn.mech_driver.test_mech_driver.TestOVNMechanismDriver.test_remove_subnet_dhcp_options_in_ovn_ipv4
----------------------------------------------------------------------
testtools.testresult.real._StringException: Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/neutron/tests/base.py", line 182, in func
return f(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py", line 1368, in test_remove_subnet_dhcp_options_in_ovn_ipv4
self._test_remove_subnet_dhcp_options_in_ovn(4)
File "/usr/lib/python3/dist-packages/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py", line 1361, in _test_remove_subnet_dhcp_options_in_ovn
self.assertEqual(
File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 415, in assertEqual
self.assertThat(observed, matcher, message)
File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 502, in assertThat
raise mismatch_error
testtools.matchers._impl.MismatchError: 2 != 1
----------------------------------------------------------------------
Ran 1 test in 3.295s
FAILED (failures=1)
Assuming this unit test failure is expected with a empty
dhcp_options['subnet'] directory, the fix is verified since we no longer
see the UUID KeyError.
--
You received this bug notification because you are a member of Ubuntu
OpenStack, which is subscribed to Ubuntu Cloud Archive.
https://bugs.launchpad.net/bugs/1948466
Title:
[OVN] Mech driver fails to delete DHCP options during subnet deletion
Status in Ubuntu Cloud Archive:
Fix Released
Status in Ubuntu Cloud Archive ussuri series:
Fix Committed
Status in neutron:
Fix Released
Status in neutron package in Ubuntu:
Fix Released
Status in neutron source package in Focal:
Fix Committed
Bug description:
== Original Bug Description ==
Snippet: https://paste.opendev.org/show/810168/
I can't provide a link to a CI execution, I saw this error in an
internal CI. I'm still investigating when this could happen.
== Ubuntu SRU Details ==
[Impact]
During subnet deletion the check in _remove_subnet_dhcp_options()
results in the following traceback (taken from pastebin above in case
it disappears) if dhcp_options['subnet'] is an empty dictionary:
ExternalNetworksRBACTestJSON-2078932943-project-admin] Mechanism driver 'ovn' failed in delete_subnet_postcommit: KeyError: 'uuid'
Traceback (most recent call last):
File "/opt/stack/neutron/neutron/plugins/ml2/managers.py", line 482, in _call_on_drivers
getattr(driver.obj, method_name)(context)
File "/opt/stack/neutron/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py", line 637, in delete_subnet_postcommit
self._ovn_client.delete_subnet(context._plugin_context,
File "/opt/stack/neutron/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py", line 2103, in delete_subnet
self._remove_subnet_dhcp_options(subnet_id, txn)
File "/opt/stack/neutron/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py", line 1971, in _remove_subnet_dhcp_options
dhcp_options['subnet']['uuid']))
KeyError: 'uuid'
The fix ensures this check handles a dictionary correctly.
[Test Case]
In case we don't have a recreate for this:
1) lxc launch ubuntu-daily:focal f1 && lxc exec f1 /bin/bash
2) sudo add-apt-repository -p proposed
3) sudo apt install python3-neutron
4) cd /usr/lib/python3/dist-packages
5) python3 -m unittest neutron.tests.unit.plugins.ml2.drivers.ovn.mech_driver.test_mech_driver.TestOVNMechanismDriver.test_remove_subnet_dhcp_options_in_ovn_ipv4
6) re-run the test in step #5 after adding 'pdb.set_trace()' to the line before the check in neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py
this way we can see what dhcp_options['subnet'] is set to, ensure the check behaves correctly, and try another run with dhcp_options['subnet'] = {}
7) sudo add-apt-repository -r -p proposed
[Regression Potential]
This is a minimal change that is backward compatible with the previous
check. The new check can still handle 'not None' in addition to
handling an empty dictionary correctly. This has been fixed in Ubuntu
Victoria packages (and above) since 2022-01-12, and has been fixed in
the upstream stable/ussuri branch since 2021-10-25.
To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-archive/+bug/1948466/+subscriptions
More information about the Ubuntu-openstack-bugs
mailing list