Add logging for the original message

On port binding/unbinding, Kuryr catches exception raised from
pyroute2 and re-raise a new exception. As a result, the detailed
information contained in the original exception loses. This patch
adds a logging to record the original exception message and trace.

Related-Bug: #1776035
Change-Id: I4b13724a460d84a2b953f750b8b88c0f60cee97d
This commit is contained in:
Hongbin Lu 2018-06-09 17:27:19 +00:00
parent ce39e2aa44
commit 2f38e07a38
1 changed files with 6 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import pyroute2
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_log import log
from oslo_utils import excutils
from kuryr.lib.binding.drivers import utils
@ -24,6 +25,7 @@ from kuryr.lib import utils as lib_utils
KIND = 'veth'
LOG = log.getLogger(__name__)
def port_bind(endpoint_id, port, subnets, network=None, vm_port=None,
@ -65,9 +67,12 @@ def port_bind(endpoint_id, port, subnets, network=None, vm_port=None,
fixed_ips=port.get(utils.FIXED_IP_KEY),
mtu=mtu, hwaddr=port[utils.MAC_ADDRESS_KEY].lower())
except pyroute2.CreateException:
LOG.exception("Error happened during virtual device creation")
raise exceptions.VethCreationFailure(
'Virtual device creation failed.')
except pyroute2.CommitException:
LOG.exception("Error happened during configuring the container "
"virtual device networking")
raise exceptions.VethCreationFailure(
'Could not configure the container virtual device networking.')
@ -113,6 +118,7 @@ def port_unbind(endpoint_id, neutron_port, **kwargs):
try:
utils.remove_device(ifname)
except pyroute2.NetlinkError:
LOG.exception("Error happened during deleting the veth pair")
raise exceptions.VethDeletionFailure(
'Deleting the veth pair failed.')
return (stdout, stderr)