Handle not found subport on Trunk

When a namespace is created-deleted-created, the last namespace
creation event might notices that a KuryrNet CRD still exists,
as it can take a while for the previous deletion event to complete
and will trigger again another deletion causing NotFound SubPort
on Trunk error. This commit handles the exception by ignoring
the port deletion.

Change-Id: Id0683a00b2c90529e0106296b5f157cf6885388b
Closes-bug: 1854096
This commit is contained in:
Maysa Macedo 2019-11-26 20:57:40 +00:00
parent 73e8336fbb
commit 28b79999a0
1 changed files with 7 additions and 3 deletions

View File

@ -129,9 +129,13 @@ class NamespacePodSubnetDriver(default_subnet.DefaultPodSubnetDriver):
# Get the trunk_id from the error message
trunk_id = (
str(e).split('trunk')[1].split('.')[0].strip())
neutron.trunk_remove_subports(
trunk_id, {'sub_ports': [
{'port_id': leftover_port['id']}]})
try:
neutron.trunk_remove_subports(
trunk_id, {'sub_ports': [
{'port_id': leftover_port['id']}]})
except n_exc.NotFound:
LOG.debug("Port %s already removed from trunk %s",
leftover_port['id'], trunk_id)
else:
LOG.exception("Unexpected error deleting leftover "
"port %s. Skiping it and continue with "