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,
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@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 due to the hardcoded null value while the test itself does,
dhcp_options['subnet'] = {} <-- hard coded to empty print(dhcp_options['subnet'])
if dhcp_options['subnet']: txn.add(self._nb_idl.delete_dhcp_options( dhcp_options['subnet']['uuid']))
root@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.
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)
if dhcp_options[
root@juju- 3b1260- fixtestnew- 6:/usr/ lib/python3/ dist-packages# python3 -m unittest neutron. tests.unit. plugins. ml2.drivers. ovn.mech_ driver. test_mech_ driver. TestOVNMechanis mDriver. test_remove_ subnet_ dhcp_options_ in_ovn_ ipv4 python3/ dist-packages/ neutron_ lib/worker. py:68: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats _parent_ proctitle = setproctitle. getproctitle( ) ======= ======= ======= ======= ======= ======= ======= ======= ======= subnet_ dhcp_options_ in_ovn_ ipv4 (neutron. tests.unit. plugins. ml2.drivers. ovn.mech_ driver. test_mech_ driver. TestOVNMechanis mDriver) tests.unit. plugins. ml2.drivers. ovn.mech_ driver. test_mech_ driver. TestOVNMechanis mDriver. test_remove_ subnet_ dhcp_options_ in_ovn_ ipv4 ------- ------- ------- ------- ------- ------- ------- ------- ------- testresult. real._StringExc eption: Traceback (most recent call last): python3/ dist-packages/ neutron/ tests/base. py", line 182, in func 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 _test_remove_ subnet_ dhcp_options_ in_ovn( 4) 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 mech_driver. _ovn_client. _remove_ subnet_ dhcp_options( python3/ dist-packages/ neutron/ plugins/ ml2/drivers/ ovn/mech_ driver/ ovsdb/ovn_ client. py", line 1893, in _remove_ subnet_ dhcp_options options[ 'subnet' ]['uuid' ]))
/usr/lib/
self.
{}
E
=======
ERROR: test_remove_
neutron.
-------
testtools.
File "/usr/lib/
return f(self, *args, **kwargs)
File "/usr/lib/
self.
File "/usr/lib/
self.
File "/usr/lib/
dhcp_
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 due to the hardcoded null value while the test itself does,
# Check deleting DHCP_Options rows
delete_ dhcp_calls = [mock.call( 'subnet- uuid'), mock.call( 'port1- uuid')] <-- passing subnet-uuid
self.assertEqu al(
len( delete_ dhcp_calls) ,
self. mech_driver. _nb_ovn. delete_ dhcp_options. call_count)
self.mech_ driver. _nb_ovn. delete_ dhcp_options. assert_ has_calls(
delete_ dhcp_calls, any_order=True)
the code looks like,
def _remove_ subnet_ dhcp_options( self, subnet_id, txn):
dhcp_options = self._nb_ idl.get_ subnet_ dhcp_options(
subnet_ id, with_ports=True)
if dhcp_options[
root@juju- 3b1260- fixtestnew- 6:/usr/ lib/python3/ dist-packages# python3 -m unittest neutron. tests.unit. plugins. ml2.drivers. ovn.mech_ driver. test_mech_ driver. TestOVNMechanis mDriver. test_remove_ subnet_ dhcp_options_ in_ovn_ ipv4 python3/ dist-packages/ neutron_ lib/worker. py:68: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats _parent_ proctitle = setproctitle. getproctitle( ) ======= ======= ======= ======= ======= ======= ======= ======= ======= subnet_ dhcp_options_ in_ovn_ ipv4 (neutron. tests.unit. plugins. ml2.drivers. ovn.mech_ driver. test_mech_ driver. TestOVNMechanis mDriver) tests.unit. plugins. ml2.drivers. ovn.mech_ driver. test_mech_ driver. TestOVNMechanis mDriver. test_remove_ subnet_ dhcp_options_ in_ovn_ ipv4 ------- ------- ------- ------- ------- ------- ------- ------- ------- testresult. real._StringExc eption: Traceback (most recent call last): python3/ dist-packages/ neutron/ tests/base. py", line 182, in func 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 _test_remove_ subnet_ dhcp_options_ in_ovn( 4) 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 assertEqual( python3/ dist-packages/ testtools/ testcase. py", line 415, in assertEqual assertThat( observed, matcher, message) python3/ dist-packages/ testtools/ testcase. py", line 502, in assertThat matchers. _impl.MismatchE rror: 2 != 1
/usr/lib/
self.
{}
F
=======
FAIL: test_remove_
neutron.
-------
testtools.
File "/usr/lib/
return f(self, *args, **kwargs)
File "/usr/lib/
self.
File "/usr/lib/
self.
File "/usr/lib/
self.
File "/usr/lib/
raise mismatch_error
testtools.
------- ------- ------- ------- ------- ------- ------- ------- ------- -------
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.