Merge "[OVN] Remove maintenance method `add_vnic_type_and_pb_capabilities_to_lsp`"

This commit is contained in:
Zuul 2024-10-25 11:14:36 +00:00 committed by Gerrit Code Review
commit 55cfc9a2b0
2 changed files with 0 additions and 62 deletions

View File

@ -29,7 +29,6 @@ from neutron_lib import exceptions as n_exc
from neutron_lib.exceptions import l3 as l3_exc
from oslo_config import cfg
from oslo_log import log
from oslo_serialization import jsonutils
from oslo_utils import strutils
from oslo_utils import timeutils
from ovsdbapp.backend.ovs_idl import event as row_event
@ -821,42 +820,6 @@ class DBInconsistenciesPeriodics(SchemaAwarePeriodicsBase):
raise periodics.NeverAgain()
# TODO(ralonsoh): Remove this in the Antelope+4 cycle
@has_lock_periodic(
periodic_run_limit=ovn_const.MAINTENANCE_TASK_RETRY_LIMIT,
spacing=ovn_const.MAINTENANCE_ONE_RUN_TASK_SPACING,
run_immediately=True)
def add_vnic_type_and_pb_capabilities_to_lsp(self):
"""Add the port VNIC type and port binding capabilities to the LSP.
This is needed to know if a port has hardware offload capabilities.
This method is only updating those ports with VNIC type direct, in
order to minimize the load impact of this method when updating the OVN
database. Within the patch that adds this maintenance method, it has
been added to the LSP the VNIC type and the port binding capabilities.
To implement LP#1998608, only direct ports are needed.
"""
port_bindings = ports_obj.PortBinding.get_port_binding_by_vnic_type(
n_context.get_admin_context(), portbindings.VNIC_DIRECT)
with self._nb_idl.transaction(check_error=True) as txn:
for pb in port_bindings:
try:
profile = jsonutils.loads(pb.profile)
except ValueError:
continue
capabilities = profile.get(ovn_const.PORT_CAP_PARAM, [])
external_ids = {
ovn_const.OVN_PORT_VNIC_TYPE_KEY: portbindings.VNIC_DIRECT,
ovn_const.OVN_PORT_BP_CAPABILITIES_KEY:
';'.join(capabilities)
}
txn.add(self._nb_idl.set_lswitch_port(
lport_name=pb.port_id, if_exists=True,
external_ids=external_ids))
raise periodics.NeverAgain()
@has_lock_periodic(
periodic_run_limit=ovn_const.MAINTENANCE_TASK_RETRY_LIMIT,
spacing=ovn_const.MAINTENANCE_ONE_RUN_TASK_SPACING,

View File

@ -17,12 +17,10 @@ from unittest import mock
from futurist import periodics
from neutron_lib.api.definitions import external_net
from neutron_lib.api.definitions import portbindings
from neutron_lib import constants as n_const
from neutron_lib import context
from neutron_lib.db import api as db_api
from oslo_config import cfg
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
from neutron.common.ovn import constants
@ -30,7 +28,6 @@ from neutron.common.ovn import utils
from neutron.conf.plugins.ml2.drivers.ovn import ovn_conf
from neutron.db.models import ovn as ovn_models
from neutron.db import ovn_revision_numbers_db
from neutron.objects import ports as ports_obj
from neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb import maintenance
from neutron.tests import base
from neutron.tests.unit import fake_resources as fakes
@ -821,28 +818,6 @@ class TestDBInconsistenciesPeriodics(testlib_api.SqlTestCaseLight,
1,
nb_idl.delete_static_routes.call_count)
@mock.patch.object(ports_obj.PortBinding, 'get_port_binding_by_vnic_type')
def test_add_vnic_type_and_pb_capabilities_to_lsp(self, mock_get_pb):
nb_idl = self.fake_ovn_client._nb_idl
profile = {'capabilities': ['switchdev']}
pb1 = mock.Mock(profile=jsonutils.dumps(profile), port_id='port1')
pb2 = mock.Mock(profile=jsonutils.dumps(profile), port_id='port2')
pb3 = mock.Mock(profile='', port_id='port3')
mock_get_pb.return_value = [pb1, pb2, pb3]
self.assertRaises(
periodics.NeverAgain,
self.periodic.add_vnic_type_and_pb_capabilities_to_lsp)
external_ids = {
constants.OVN_PORT_VNIC_TYPE_KEY: portbindings.VNIC_DIRECT,
constants.OVN_PORT_BP_CAPABILITIES_KEY: 'switchdev'}
expected_calls = [mock.call(lport_name='port1', if_exists=True,
external_ids=external_ids),
mock.call(lport_name='port2', if_exists=True,
external_ids=external_ids)]
nb_idl.set_lswitch_port.assert_has_calls(expected_calls)
self.assertEqual(2, nb_idl.set_lswitch_port.call_count)
def test_update_nat_floating_ip_with_gateway_port(self):
_nb_idl = self.fake_ovn_client._nb_idl
utils.is_nat_gateway_port_supported.return_value = True