From: Zack Cerza Date: Tue, 31 May 2016 15:54:34 +0000 (-0600) Subject: pcp: Don't fail a job if graph downloading fails X-Git-Tag: 1.1.0~607^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F867%2Fhead;p=teuthology.git pcp: Don't fail a job if graph downloading fails http://tracker.ceph.com/issues/16049 Fixes: 16049 Signed-off-by: Zack Cerza --- diff --git a/teuthology/task/pcp.py b/teuthology/task/pcp.py index c368936de..0c384b97e 100644 --- a/teuthology/task/pcp.py +++ b/teuthology/task/pcp.py @@ -310,8 +310,12 @@ class PCP(Task): if hasattr(self.ctx, 'summary'): self.ctx.summary['pcp_grafana_url'] = grafana_url if self.use_graphite: - self.graphite.download_graphs() - self.graphite.write_html(mode='static') + try: + self.graphite.download_graphs() + self.graphite.write_html(mode='static') + except requests.ConnectionError: + log.exception("Downloading graphs failed!") + self.graphite.write_html() if self.fetch_archives: for remote in self.cluster.remotes.keys(): log.info("Copying PCP data into archive...") diff --git a/teuthology/test/task/test_pcp.py b/teuthology/test/task/test_pcp.py index 3d4dde0cf..0e1323402 100644 --- a/teuthology/test/task/test_pcp.py +++ b/teuthology/test/task/test_pcp.py @@ -1,7 +1,8 @@ import os +import requests import urlparse -from mock import patch, DEFAULT, Mock, MagicMock +from mock import patch, DEFAULT, Mock, MagicMock, call from pytest import raises from teuthology.config import config, FakeNamespace @@ -362,3 +363,18 @@ class TestPCPTask(TestTask): second_call = task.graphite.write_html.call_args_list[1] assert second_call[1]['mode'] == 'static' assert isinstance(task.stop_time, int) + + @patch('os.makedirs') + @patch('teuthology.task.pcp.GrafanaGrapher') + @patch('teuthology.task.pcp.GraphiteGrapher') + def test_end_16049(self, m_grafana, m_graphite, m_makedirs): + # http://tracker.ceph.com/issues/16049 + # Jobs were failing if graph downloading failed. We don't want that. + self.ctx.archive = '/fake/path' + with self.klass(self.ctx, self.task_config) as task: + task.graphite.download_graphs.side_effect = \ + requests.ConnectionError + # Even though downloading graphs failed, we should have called + # write_html() a second time, again with no args + assert task.graphite.write_html.call_args_list == [call(), call()] + assert isinstance(task.stop_time, int)