Skip to content

Commit deb0153

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Check if port exists in update_port_virtual_type method" into stable/yoga
2 parents da4096d + 951e2c7 commit deb0153

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,11 @@ def update_port_virtual_type(self):
868868
if lsp.type != '':
869869
continue
870870

871-
port = self._ovn_client._plugin.get_port(context, lsp.name)
871+
try:
872+
port = self._ovn_client._plugin.get_port(context, lsp.name)
873+
except n_exc.PortNotFound:
874+
continue
875+
872876
for ip in port.get('fixed_ips', []):
873877
if utils.get_virtual_port_parents(
874878
self._nb_idl, ip['ip_address'], port['network_id'],

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,13 @@ def test_update_port_virtual_type(self, *args):
676676
attrs={'name': 'lsp0', 'type': ''})
677677
lsp1 = fakes.FakeOvsdbRow.create_one_ovsdb_row(
678678
attrs={'name': 'lsp1', 'type': constants.LSP_TYPE_VIRTUAL})
679+
lsp2 = fakes.FakeOvsdbRow.create_one_ovsdb_row(
680+
attrs={'name': 'lsp2_not_present_in_neutron_db', 'type': ''})
679681
port0 = {'fixed_ips': [{'ip_address': mock.ANY}],
680682
'network_id': mock.ANY, 'id': mock.ANY}
681-
nb_idl.lsp_list.return_value.execute.return_value = (lsp0, lsp1)
682-
self.fake_ovn_client._plugin.get_port.return_value = port0
683+
nb_idl.lsp_list.return_value.execute.return_value = (lsp0, lsp1, lsp2)
684+
self.fake_ovn_client._plugin.get_port.side_effect = [
685+
port0, n_exc.PortNotFound(port_id=mock.ANY)]
683686

684687
self.assertRaises(
685688
periodics.NeverAgain, self.periodic.update_port_virtual_type)

0 commit comments

Comments
 (0)