[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:
parent
bdea142584
commit
3c637a2d12
|
@ -70,29 +70,29 @@ def migrate_neutron_database_to_ovn():
|
||||||
break
|
break
|
||||||
|
|
||||||
for port_id, host in diff:
|
for port_id, host in diff:
|
||||||
with db_api.CONTEXT_WRITER.using(ctx):
|
try:
|
||||||
pb = port_obj.PortBinding.get_object(ctx, port_id=port_id,
|
with db_api.CONTEXT_WRITER.using(ctx):
|
||||||
host=host)
|
pb = port_obj.PortBinding.get_object(ctx, port_id=port_id,
|
||||||
if not pb or not pb.vif_details:
|
host=host)
|
||||||
continue
|
if not pb or not pb.vif_details:
|
||||||
|
continue
|
||||||
|
|
||||||
vif_details = pb.vif_details.copy()
|
vif_details = pb.vif_details.copy()
|
||||||
for detail in VIF_DETAILS_TO_REMOVE:
|
for detail in VIF_DETAILS_TO_REMOVE:
|
||||||
try:
|
try:
|
||||||
del vif_details[detail]
|
del vif_details[detail]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
if vif_details == pb.vif_details:
|
if vif_details == pb.vif_details:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
pb.vif_details = vif_details
|
pb.vif_details = vif_details
|
||||||
try:
|
|
||||||
pb.update()
|
pb.update()
|
||||||
except (exceptions.ObjectNotFound,
|
except (exceptions.ObjectNotFound,
|
||||||
sqla_exc.StaleDataError,
|
sqla_exc.StaleDataError,
|
||||||
db_exc.DBDeadlock):
|
db_exc.DBDeadlock):
|
||||||
# The PortBinding register has been already modified.
|
# The PortBinding register has been already modified.
|
||||||
pb_missed.add(port_id)
|
pb_missed.add(port_id)
|
||||||
|
|
||||||
pb_updated.update(diff)
|
pb_updated.update(diff)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue