@@ -320,7 +320,7 @@ def migrate_to_stateful_fips(self):
320
320
# to perform the migration every 10 seconds until completed.
321
321
# TODO(jlibosva): Remove the migration to port groups at some point. It's
322
322
# 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 )
324
324
@rerun_on_schema_updates
325
325
def migrate_to_port_groups (self ):
326
326
"""Perform the migration from Address Sets to Port Groups. """
@@ -332,11 +332,6 @@ def migrate_to_port_groups(self):
332
332
if not self ._nb_idl .get_address_sets ():
333
333
raise periodics .NeverAgain ()
334
334
335
- # Only the worker holding a valid lock within OVSDB will perform the
336
- # migration.
337
- if not self .has_lock :
338
- return
339
-
340
335
admin_context = n_context .get_admin_context ()
341
336
nb_sync = ovn_db_sync .OvnNbSynchronizer (
342
337
self ._ovn_client ._plugin , self ._nb_idl , self ._ovn_client ._sb_idl ,
@@ -579,16 +574,13 @@ def _delete_default_ha_chassis_group(self, txn):
579
574
580
575
# A static spacing value is used here, but this method will only run
581
576
# 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 )
583
578
def check_for_ha_chassis_group (self ):
584
579
# If external ports is not supported stop running
585
580
# this periodic task
586
581
if not self ._ovn_client .is_external_ports_supported ():
587
582
raise periodics .NeverAgain ()
588
583
589
- if not self .has_lock :
590
- return
591
-
592
584
external_ports = self ._nb_idl .db_find_rows (
593
585
'Logical_Switch_Port' , ('type' , '=' , ovn_const .LSP_TYPE_EXTERNAL )
594
586
).execute (check_error = True )
@@ -680,16 +672,13 @@ def check_router_mac_binding_options(self):
680
672
# TODO(ralonsoh): Remove this in the Z+2 cycle
681
673
# A static spacing value is used here, but this method will only run
682
674
# 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 )
684
676
def update_port_qos_with_external_ids_reference (self ):
685
677
"""Update all OVN QoS registers with the port ID
686
678
687
679
This method will only update the OVN QoS registers related to port QoS,
688
680
not FIP QoS. FIP QoS have the corresponding "external_ids" reference.
689
681
"""
690
- if not self .has_lock :
691
- return
692
-
693
682
regex = re .compile (
694
683
r'(inport|outport) == \"(?P<port_id>[a-z0-9\-]{36})\"' )
695
684
cmds = []
@@ -840,7 +829,7 @@ def update_logical_router_with_gateway_network_id(self):
840
829
841
830
# A static spacing value is used here, but this method will only run
842
831
# 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 )
844
833
def check_baremetal_ports_dhcp_options (self ):
845
834
"""Update baremetal ports DHCP options
846
835
@@ -852,9 +841,6 @@ def check_baremetal_ports_dhcp_options(self):
852
841
if not self ._ovn_client .is_external_ports_supported ():
853
842
raise periodics .NeverAgain ()
854
843
855
- if not self .has_lock :
856
- return
857
-
858
844
context = n_context .get_admin_context ()
859
845
ports = ports_obj .Port .get_ports_by_vnic_type_and_host (
860
846
context , portbindings .VNIC_BAREMETAL )
@@ -1056,7 +1042,7 @@ def check_fair_meter_consistency(self):
1056
1042
from_reload = True )
1057
1043
raise periodics .NeverAgain ()
1058
1044
1059
- @periodics . periodic (spacing = 300 , run_immediately = True )
1045
+ @has_lock_periodic (spacing = 300 , run_immediately = True )
1060
1046
def remove_duplicated_chassis_registers (self ):
1061
1047
"""Remove the "Chassis" and "Chassis_Private" duplicated registers.
1062
1048
@@ -1075,9 +1061,6 @@ def remove_duplicated_chassis_registers(self):
1075
1061
if not self ._sb_idl .is_table_present ('Chassis_Private' ):
1076
1062
raise periodics .NeverAgain ()
1077
1063
1078
- if not self .has_lock :
1079
- return
1080
-
1081
1064
# dup_chassis_port_host = {host_name: [(ch1, ch_private1),
1082
1065
# (ch2, ch_private2), ... ]}
1083
1066
dup_chassis_port_host = {}
0 commit comments