[OVN]: Make _delete_port() more error-resilent

This patch is making the transaction from the _delete_port() method in
OVNClient more resilient to errors where elements from that transaction
have already been deleted by another change in the database.

Prior to this patch, a few places could potentially raise RowNotFound
which would abort the whole transaction and would leave the a stable
port for being cleaned up after by the maintenance thread. This patch
tries to catch those exceptions that could potentially fail the
transaction.

Change-Id: I8fd1d1485269d23529a19085bd4aa4c6c74f5f91
Partial-Bug: #1874733
Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
This commit is contained in:
Lucas Alvares Gomes 2020-05-01 13:12:53 +01:00
parent 34448578cb
commit 8b234d8786
2 changed files with 17 additions and 4 deletions

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from ovsdbapp.backend.ovs_idl import idlutils
from neutron.objects.qos import binding as qos_binding
from neutron.objects.qos import policy as qos_policy
from neutron.objects.qos import rule as qos_rule
@ -159,7 +161,12 @@ class OVNClientQosExtension(object):
for ovn_rule in [self._ovn_qos_rule(direction, {}, port_id,
network_id, delete=True)
for direction in constants.VALID_DIRECTIONS]:
txn.add(self._driver._nb_idl.qos_del(**ovn_rule))
# TODO(lucasagomes): qos_del() in ovsdbapp doesn't support
# if_exists=True
try:
txn.add(self._driver._nb_idl.qos_del(**ovn_rule))
except idlutils.RowNotFound:
continue
if not qos_policy_id:
return # If no QoS policy is defined, there are no QoS rules.

View File

@ -663,7 +663,11 @@ class OVNClient(object):
db_rev.bump_revision(context, port, ovn_const.TYPE_PORTS)
def _delete_port(self, port_id, port_object=None):
ovn_port = self._nb_idl.lookup('Logical_Switch_Port', port_id)
ovn_port = self._nb_idl.lookup(
'Logical_Switch_Port', port_id, default=None)
if ovn_port is None:
return
network_id = ovn_port.external_ids.get(
ovn_const.OVN_NETWORK_NAME_EXT_ID_KEY)
@ -677,7 +681,8 @@ class OVNClient(object):
port_id, network_id))
if not self._nb_idl.is_port_groups_supported():
txn.add(self._nb_idl.delete_acl(network_id, port_id))
txn.add(self._nb_idl.delete_acl(
network_id, port_id, if_exists=True))
addresses = utils.sort_ips_by_version(
utils.get_ovn_port_addresses(ovn_port))
@ -690,7 +695,8 @@ class OVNClient(object):
txn.add(self._nb_idl.update_address_set(
name=utils.ovn_addrset_name(sg_id, ip_version),
addrs_add=None,
addrs_remove=addr_list))
addrs_remove=addr_list,
if_exists=True))
p_object = ({'id': port_id, 'network_id': network_id}
if not port_object else port_object)