Dump metric exception text to logs
This patch simply adds the exception text to the logs so that we don't lose the troubleshooting data. Without this patch, it's much more difficult to troubleshoot when something goes wrong as the root exception text is garbled up and lost. Change-Id: Ib432fddc9b31fb6f906f6828d52098c9dd059aa2 Closes-Bug: 1553319
This commit is contained in:
parent
c5a45a2984
commit
aef7a3dab1
|
@ -465,8 +465,10 @@ class ResourceTracker(object):
|
|||
for monitor in self.monitors:
|
||||
try:
|
||||
monitor.add_metrics_to_list(metrics)
|
||||
except Exception:
|
||||
LOG.warning(_LW("Cannot get the metrics from %s."), monitor)
|
||||
except Exception as exc:
|
||||
LOG.warning(_LW("Cannot get the metrics from %(mon)s; "
|
||||
"error: %(exc)s"),
|
||||
{'mon': monitor, 'exc': exc})
|
||||
# TODO(jaypipes): Remove this when compute_node.metrics doesn't need
|
||||
# to be populated as a JSON-ified string.
|
||||
metrics = metrics.to_list()
|
||||
|
|
|
@ -1211,7 +1211,7 @@ class ComputeMonitorTestCase(BaseTestCase):
|
|||
metrics = self.tracker._get_host_metrics(self.context,
|
||||
self.node_name)
|
||||
mock_LOG_warning.assert_called_once_with(
|
||||
u'Cannot get the metrics from %s.', mock.ANY)
|
||||
u'Cannot get the metrics from %(mon)s; error: %(exc)s', mock.ANY)
|
||||
self.assertEqual(0, len(metrics))
|
||||
|
||||
def test_get_host_metrics(self):
|
||||
|
|
Loading…
Reference in New Issue