Skip to content

Commit 5072af6

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Use has_lock_periodic decorator for the tasks which require ovn db lock" into stable/2023.1
2 parents 0326239 + 078256c commit 5072af6

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def migrate_to_stateful_fips(self):
320320
# to perform the migration every 10 seconds until completed.
321321
# TODO(jlibosva): Remove the migration to port groups at some point. It's
322322
# been around since Queens release so it is good to drop this soon.
323-
@periodics.periodic(spacing=10, run_immediately=True)
323+
@has_lock_periodic(spacing=10, run_immediately=True)
324324
@rerun_on_schema_updates
325325
def migrate_to_port_groups(self):
326326
"""Perform the migration from Address Sets to Port Groups. """
@@ -332,11 +332,6 @@ def migrate_to_port_groups(self):
332332
if not self._nb_idl.get_address_sets():
333333
raise periodics.NeverAgain()
334334

335-
# Only the worker holding a valid lock within OVSDB will perform the
336-
# migration.
337-
if not self.has_lock:
338-
return
339-
340335
admin_context = n_context.get_admin_context()
341336
nb_sync = ovn_db_sync.OvnNbSynchronizer(
342337
self._ovn_client._plugin, self._nb_idl, self._ovn_client._sb_idl,
@@ -579,16 +574,13 @@ def _delete_default_ha_chassis_group(self, txn):
579574

580575
# A static spacing value is used here, but this method will only run
581576
# once per lock due to the use of periodics.NeverAgain().
582-
@periodics.periodic(spacing=600, run_immediately=True)
577+
@has_lock_periodic(spacing=600, run_immediately=True)
583578
def check_for_ha_chassis_group(self):
584579
# If external ports is not supported stop running
585580
# this periodic task
586581
if not self._ovn_client.is_external_ports_supported():
587582
raise periodics.NeverAgain()
588583

589-
if not self.has_lock:
590-
return
591-
592584
external_ports = self._nb_idl.db_find_rows(
593585
'Logical_Switch_Port', ('type', '=', ovn_const.LSP_TYPE_EXTERNAL)
594586
).execute(check_error=True)
@@ -680,16 +672,13 @@ def check_router_mac_binding_options(self):
680672
# TODO(ralonsoh): Remove this in the Z+2 cycle
681673
# A static spacing value is used here, but this method will only run
682674
# once per lock due to the use of periodics.NeverAgain().
683-
@periodics.periodic(spacing=600, run_immediately=True)
675+
@has_lock_periodic(spacing=600, run_immediately=True)
684676
def update_port_qos_with_external_ids_reference(self):
685677
"""Update all OVN QoS registers with the port ID
686678
687679
This method will only update the OVN QoS registers related to port QoS,
688680
not FIP QoS. FIP QoS have the corresponding "external_ids" reference.
689681
"""
690-
if not self.has_lock:
691-
return
692-
693682
regex = re.compile(
694683
r'(inport|outport) == \"(?P<port_id>[a-z0-9\-]{36})\"')
695684
cmds = []
@@ -840,7 +829,7 @@ def update_logical_router_with_gateway_network_id(self):
840829

841830
# A static spacing value is used here, but this method will only run
842831
# once per lock due to the use of periodics.NeverAgain().
843-
@periodics.periodic(spacing=600, run_immediately=True)
832+
@has_lock_periodic(spacing=600, run_immediately=True)
844833
def check_baremetal_ports_dhcp_options(self):
845834
"""Update baremetal ports DHCP options
846835
@@ -852,9 +841,6 @@ def check_baremetal_ports_dhcp_options(self):
852841
if not self._ovn_client.is_external_ports_supported():
853842
raise periodics.NeverAgain()
854843

855-
if not self.has_lock:
856-
return
857-
858844
context = n_context.get_admin_context()
859845
ports = ports_obj.Port.get_ports_by_vnic_type_and_host(
860846
context, portbindings.VNIC_BAREMETAL)
@@ -1056,7 +1042,7 @@ def check_fair_meter_consistency(self):
10561042
from_reload=True)
10571043
raise periodics.NeverAgain()
10581044

1059-
@periodics.periodic(spacing=300, run_immediately=True)
1045+
@has_lock_periodic(spacing=300, run_immediately=True)
10601046
def remove_duplicated_chassis_registers(self):
10611047
"""Remove the "Chassis" and "Chassis_Private" duplicated registers.
10621048
@@ -1075,9 +1061,6 @@ def remove_duplicated_chassis_registers(self):
10751061
if not self._sb_idl.is_table_present('Chassis_Private'):
10761062
raise periodics.NeverAgain()
10771063

1078-
if not self.has_lock:
1079-
return
1080-
10811064
# dup_chassis_port_host = {host_name: [(ch1, ch_private1),
10821065
# (ch2, ch_private2), ... ]}
10831066
dup_chassis_port_host = {}

0 commit comments

Comments
 (0)