Merge "Dump metric exception text to logs"

This commit is contained in:
Jenkins 2016-03-07 07:00:15 +00:00 committed by Gerrit Code Review
commit 38c3f883db
2 changed files with 5 additions and 3 deletions

View File

@ -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()

View File

@ -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):