|
25 | 25 | from neutron_lib.plugins import directory |
26 | 26 | from neutron_lib.utils import helpers |
27 | 27 | from oslo_log import log |
| 28 | +from ovsdbapp.backend.ovs_idl import idlutils |
28 | 29 |
|
29 | 30 | from neutron.common.ovn import acl as acl_utils |
30 | 31 | from neutron.common.ovn import constants as ovn_const |
@@ -99,7 +100,6 @@ def do_sync(self): |
99 | 100 | LOG.debug("Starting OVN-Northbound DB sync process") |
100 | 101 |
|
101 | 102 | ctx = context.get_admin_context() |
102 | | - |
103 | 103 | self.sync_port_groups(ctx) |
104 | 104 | self.sync_networks_ports_and_dhcp_opts(ctx) |
105 | 105 | self.sync_port_dns_records(ctx) |
@@ -298,11 +298,32 @@ def get_num_acls(ovn_acls): |
298 | 298 | 'remove': num_acls_to_remove}) |
299 | 299 |
|
300 | 300 | if self.mode == SYNC_MODE_REPAIR: |
301 | | - with self.ovn_api.transaction(check_error=True) as txn: |
302 | | - for acla in neutron_acls: |
303 | | - LOG.warning('ACL found in Neutron but not in ' |
304 | | - 'OVN DB for port group %s', acla['port_group']) |
305 | | - txn.add(self.ovn_api.pg_acl_add(**acla, may_exist=True)) |
| 301 | + pg_resync_count = 0 |
| 302 | + while True: |
| 303 | + try: |
| 304 | + with self.ovn_api.transaction(check_error=True) as txn: |
| 305 | + for acla in neutron_acls: |
| 306 | + LOG.warning('ACL found in Neutron but not in ' |
| 307 | + 'OVN DB for port group %s', |
| 308 | + acla['port_group']) |
| 309 | + txn.add(self.ovn_api.pg_acl_add( |
| 310 | + **acla, may_exist=True)) |
| 311 | + except idlutils.RowNotFound as row_err: |
| 312 | + if row_err.msg.startswith("Cannot find Port_Group"): |
| 313 | + if pg_resync_count < 1: |
| 314 | + LOG.warning('Port group row was not found during ' |
| 315 | + 'ACLs sync. Will attempt to sync port ' |
| 316 | + 'groups one more time. The caught ' |
| 317 | + 'exception is: %s', row_err) |
| 318 | + self.sync_port_groups(ctx) |
| 319 | + pg_resync_count += 1 |
| 320 | + continue |
| 321 | + LOG.error('Port group exception during ACL sync ' |
| 322 | + 'even after one more port group resync. ' |
| 323 | + 'The caught exception is: %s', row_err) |
| 324 | + else: |
| 325 | + raise |
| 326 | + break |
306 | 327 |
|
307 | 328 | with self.ovn_api.transaction(check_error=True) as txn: |
308 | 329 | for aclr in ovn_acls: |
|
0 commit comments