From b96d8094ba91f8c632687854a3f68e9874b7aa27 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Tue, 31 May 2016 09:54:34 -0600 Subject: [PATCH] pcp: Don't fail a job if graph downloading fails http://tracker.ceph.com/issues/16049 Fixes: 16049 Signed-off-by: Zack Cerza --- teuthology/task/pcp.py | 8 ++++++-- teuthology/test/task/test_pcp.py | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) 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) -- 2.47.3