Ensure driver error preventing trunk port deletion is logged

When trunk port deletion is attempted but fails because the driver does
not permit it, the logs do not contain the driver error message that
specifies the precise rationale for preventing the trunk port deletion.
Log it explicitly.

Change-Id: I7ed1a742849dfce9e65b8eb36566112501fb0e39
(cherry picked from commit 3b56299e1f)
This commit is contained in:
Nate Johnston 2020-01-09 17:18:51 -05:00 committed by Nate Johnston
parent 530f6d5b44
commit 16699a42a9
1 changed files with 13 additions and 3 deletions

View File

@ -25,6 +25,7 @@ from neutron_lib.db import resource_extend
from neutron_lib.plugins import directory from neutron_lib.plugins import directory
from neutron_lib.services import base as service_base from neutron_lib.services import base as service_base
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import uuidutils from oslo_utils import uuidutils
from neutron.db import common_db_mixin from neutron.db import common_db_mixin
@ -269,12 +270,21 @@ class TrunkPlugin(service_base.ServicePluginBase,
# object disappears from the datastore, therefore there is no # object disappears from the datastore, therefore there is no
# status transition involved. If PRECOMMIT failures occur, # status transition involved. If PRECOMMIT failures occur,
# the trunk remains in the status where it was. # the trunk remains in the status where it was.
trunk.delete() try:
trunk.delete()
except Exception as e:
with excutils.save_and_reraise_exception():
LOG.warning('Trunk driver raised exception when '
'deleting trunk port %s: %s', trunk_id,
str(e))
payload = callbacks.TrunkPayload(context, trunk_id, payload = callbacks.TrunkPayload(context, trunk_id,
original_trunk=trunk) original_trunk=trunk)
registry.notify(constants.TRUNK, events.PRECOMMIT_DELETE, self, registry.notify(resources.TRUNK,
payload=payload) events.PRECOMMIT_DELETE,
self, payload=payload)
else: else:
LOG.info('Trunk driver does not consider trunk %s '
'untrunkable', trunk_id)
raise trunk_exc.TrunkInUse(trunk_id=trunk_id) raise trunk_exc.TrunkInUse(trunk_id=trunk_id)
registry.notify(constants.TRUNK, events.AFTER_DELETE, self, registry.notify(constants.TRUNK, events.AFTER_DELETE, self,
payload=payload) payload=payload)