[OVN] During the DB migration, allow the DB context to finish

During the execution of "migrate_neutron_database_to_ovn", that is
part of the OVN database migration process, the port bindings are
updated. If by any circumstance a port binding update fails, the
database write context should end properly (rolling back the
transaction) and any exception raise should be catched outside it.

Closes-Bug: #1975692
Change-Id: Idc6478e6f0fd1a2825b2c978b41feb5dab903357
This commit is contained in:
Rodolfo Alonso Hernandez 2022-05-14 12:52:48 +00:00
parent bdea142584
commit 3c637a2d12
1 changed files with 20 additions and 20 deletions

View File

@ -70,6 +70,7 @@ def migrate_neutron_database_to_ovn():
break
for port_id, host in diff:
try:
with db_api.CONTEXT_WRITER.using(ctx):
pb = port_obj.PortBinding.get_object(ctx, port_id=port_id,
host=host)
@ -86,7 +87,6 @@ def migrate_neutron_database_to_ovn():
continue
pb.vif_details = vif_details
try:
pb.update()
except (exceptions.ObjectNotFound,
sqla_exc.StaleDataError,