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

This commit is contained in:
Zuul 2020-05-14 00:33:54 +00:00 committed by Gerrit Code Review
commit cb55643a06
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)