Browse Source

Merge "[OVN] Fix RowNotFound exception while waiting for metadata networks" into stable/victoria

changes/47/824347/1
Zuul 4 months ago committed by Gerrit Code Review
parent
commit
7a145c09f1
  1. 7
      neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py
  2. 1
      neutron/tests/unit/fake_resources.py
  3. 48
      neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl_ovn.py

7
neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py

@ -873,7 +873,12 @@ class OvsdbSbOvnIdl(sb_impl_idl.OvnSbApiIdlImpl, Backend):
def get_chassis_metadata_networks(self, chassis_name):
"""Return a list with the metadata networks the chassis is hosting."""
chassis = self.lookup('Chassis', chassis_name)
try:
chassis = self.lookup('Chassis', chassis_name)
except idlutils.RowNotFound:
LOG.warning("Couldn't find Chassis named %s in OVN while looking "
"for metadata networks", chassis_name)
return []
proxy_networks = chassis.external_ids.get(
'neutron-metadata-proxy-networks', None)
return proxy_networks.split(',') if proxy_networks else []

1
neutron/tests/unit/fake_resources.py

@ -416,6 +416,7 @@ class FakeOvsdbTable(FakeResource):
ovsdb_table_attrs = {
'rows': collections.UserDict(),
'columns': {},
'indexes': [],
}
# Overwrite default attributes.

48
neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl_ovn.py

@ -806,3 +806,51 @@ class TestNBImplIdlOvn(TestDBImplIdlOvn):
lb_row = self._find_ovsdb_fake_row(self.lb_table, 'name', 'lb_2')
lb = self.nb_ovn_idl.get_floatingip_in_nat_or_lb(fip_id)
self.assertEqual(lb['_uuid'], lb_row.uuid)
class TestSBImplIdlOvn(TestDBImplIdlOvn):
fake_set = {
'chassis': [
{'name': 'fake-chassis',
'external_ids': {'neutron-metadata-proxy-networks': 'fake-id'}}],
}
def setUp(self):
super(TestSBImplIdlOvn, self).setUp()
self.chassis_table = fakes.FakeOvsdbTable.create_one_ovsdb_table()
self._tables = {}
self._tables['Chassis'] = self.chassis_table
with mock.patch.object(impl_idl_ovn.OvsdbSbOvnIdl, 'from_worker',
return_value=mock.Mock()):
with mock.patch.object(ovs_idl.Backend, 'autocreate_indices',
create=True):
impl_idl_ovn.OvsdbSbOvnIdl.ovsdb_connection = None
self.sb_ovn_idl = impl_idl_ovn.OvsdbSbOvnIdl(mock.MagicMock())
self.sb_ovn_idl.idl.tables = self._tables
def _load_sb_db(self):
fake_chassis = TestSBImplIdlOvn.fake_set['chassis']
self._load_ovsdb_fake_rows(self.chassis_table, fake_chassis)
@mock.patch.object(impl_idl_ovn.LOG, 'warning')
def test_get_chassis_metadata_networks_chassis_empty(self, mock_log):
chassis_name = 'fake-chassis'
result = self.sb_ovn_idl.get_chassis_metadata_networks(chassis_name)
mock_log.assert_called_once_with(
"Couldn't find Chassis named %s in OVN while looking "
"for metadata networks", chassis_name)
self.assertEqual([], result)
@mock.patch.object(impl_idl_ovn.LOG, 'warning')
def test_get_chassis_metadata_networks(self, mock_log):
chassis_name = 'fake-chassis'
self._load_sb_db()
result = self.sb_ovn_idl.get_chassis_metadata_networks(chassis_name)
self.assertFalse(mock_log.called)
self.assertEqual(['fake-id'], result)

Loading…
Cancel
Save