Comment 22 for bug 1948466

Revision history for this message
nikhil kshirsagar (nkshirsagar) wrote (last edit ):

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@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,

        # Check deleting DHCP_Options rows
        delete_dhcp_calls = [mock.call('subnet-uuid'), mock.call('port1-uuid')] <-- passing subnet-uuid
        self.assertEqual(
            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)

        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.