summaryrefslogtreecommitdiff
path: root/neutron/plugins
diff options
context:
space:
mode:
authorElvira García <egarciar@redhat.com>2023-04-20 16:39:12 +0200
committerElvira García <egarciar@redhat.com>2023-05-08 17:40:21 +0200
commitc3602ac19b62b77d3cb763746e124881d4c061e4 (patch)
tree659521a220a67b0b279167d157590bd861578465 /neutron/plugins
parent232a67f44414059e20bf5277aadc43ef0fae6931 (diff)
downloadneutron-c3602ac19b62b77d3cb763746e124881d4c061e4.tar.gz
[OVN] Update ovn meter when neutron server reloads
Up until now, we needed to remove all logging objects to see the meter-band properties being changed after a server restart. Now we check for inconsistencies between the neutron configuration and the OVN meter-band object after a restart. The function create_ovn_fair_meter is now located in the ovn_driver instead of the log_driver so as to be able to call it from the maintenance task. Closes-bug: #2017145 Signed-off-by: Elvira García <egarciar@redhat.com> Change-Id: I24cef85ed68c893a740445707f88296d763c8de8
Diffstat (limited to 'neutron/plugins')
-rw-r--r--neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py19
-rw-r--r--neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py52
2 files changed, 71 insertions, 0 deletions
diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py
index 0f3deed9a1..7f4b15c0ee 100644
--- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py
+++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py
@@ -41,6 +41,7 @@ from neutron.db import ovn_revision_numbers_db as revision_numbers_db
from neutron.objects import ports as ports_obj
from neutron.objects import router as router_obj
from neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb import ovn_db_sync
+from neutron.services.logapi.drivers.ovn import driver as log_driver
CONF = cfg.CONF
@@ -1016,6 +1017,24 @@ class DBInconsistenciesPeriodics(SchemaAwarePeriodicsBase):
raise periodics.NeverAgain()
+ @periodics.periodic(spacing=600, run_immediately=True)
+ def check_fair_meter_consistency(self):
+ """Update the logging meter after neutron-server reload
+
+ When we change the rate and burst limit we need to update the fair
+ meter band to apply the new values. This is called from the ML2/OVN
+ driver after the OVN NB idl is loaded
+
+ """
+ if not self.has_lock:
+ return
+ if log_driver.OVNDriver.network_logging_supported(self._nb_idl):
+ meter_name = (
+ cfg.CONF.network_log.local_output_log_base or "acl_log_meter")
+ self._ovn_client.create_ovn_fair_meter(meter_name,
+ from_reload=True)
+ raise periodics.NeverAgain()
+
class HashRingHealthCheckPeriodics(object):
diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py
index 11650493ef..9a40a568f2 100644
--- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py
+++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py
@@ -31,6 +31,7 @@ from neutron_lib.exceptions import l3 as l3_exc
from neutron_lib.plugins import constants as plugin_constants
from neutron_lib.plugins import directory
from neutron_lib.plugins import utils as p_utils
+from neutron_lib.services.logapi import constants as log_const
from neutron_lib.utils import helpers
from neutron_lib.utils import net as n_net
from oslo_config import cfg
@@ -2647,3 +2648,54 @@ class OVNClient(object):
if ls_dns_record.records.get(ptr_record):
txn.add(self._nb_idl.dns_remove_record(
ls_dns_record.uuid, ptr_record, if_exists=True))
+
+ def create_ovn_fair_meter(self, meter_name, from_reload=False, txn=None):
+ """Create row in Meter table with fair attribute set to True.
+
+ Create a row in OVN's NB Meter table based on well-known name. This
+ method uses the network_log configuration to specify the attributes
+ of the meter. Current implementation needs only one 'fair' meter row
+ which is then referred by multiple ACL rows.
+
+ :param meter_name: ovn northbound meter name.
+ :param from_reload: whether we update the meter values or create them.
+ :txn: ovn northbound idl transaction.
+
+ """
+ meter = self._nb_idl.db_find_rows(
+ "Meter", ("name", "=", meter_name)).execute(check_error=True)
+ # The meter is created when a log object is created, not by default.
+ # This condition avoids creating the meter if it wasn't there already
+ commands = []
+ if from_reload and not meter:
+ return
+ if meter:
+ meter = meter[0]
+ meter_band = self._nb_idl.lookup("Meter_Band",
+ meter.bands[0].uuid, default=None)
+ if meter_band:
+ if all((meter.unit == "pktps",
+ meter.fair[0],
+ meter_band.rate == cfg.CONF.network_log.rate_limit,
+ meter_band.burst_size ==
+ cfg.CONF.network_log.burst_limit)):
+ # Meter (and its meter-band) unchanged: noop.
+ return
+ # Re-create meter (and its meter-band) with the new attributes.
+ # This is supposed to happen only if configuration changed, so
+ # doing updates is an overkill: better to leverage the ovsdbapp
+ # library to avoid the complexity.
+ LOG.info("Deleting outdated log fair meter %s", meter_name)
+ commands.append(self._nb_idl.meter_del(meter.uuid))
+ # Create meter
+ LOG.info("Creating network log fair meter %s", meter_name)
+ commands.append(self._nb_idl.meter_add(
+ name=meter_name,
+ unit="pktps",
+ rate=cfg.CONF.network_log.rate_limit,
+ fair=True,
+ burst_size=cfg.CONF.network_log.burst_limit,
+ may_exist=False,
+ external_ids={ovn_const.OVN_DEVICE_OWNER_EXT_ID_KEY:
+ log_const.LOGGING_PLUGIN}))
+ self._transaction(commands, txn=txn)