From adc1beffd23febfbca02c225c12e5f72ffb58c27 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 19 Jan 2017 13:47:59 +0000 Subject: [PATCH] pcp: use a timeout when downloading graphite graphs Fixes: http://tracker.ceph.com/issues/18597 Signed-off-by: John Spray --- teuthology/task/pcp.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/teuthology/task/pcp.py b/teuthology/task/pcp.py index 6f61311bc7..065bde00f1 100644 --- a/teuthology/task/pcp.py +++ b/teuthology/task/pcp.py @@ -19,6 +19,11 @@ from . import Task log = logging.getLogger(__name__) +# Because PCP output is nonessential, set a timeout to avoid stalling +# tests if the server does not respond promptly. +GRAPHITE_DOWNLOAD_TIMEOUT = 60 + + class PCPDataSource(object): def __init__(self, hosts, time_from, time_until='now'): self.hosts = hosts @@ -157,7 +162,7 @@ class GraphiteGrapher(PCPGrapher): self.dest_dir, filename, ) - resp = requests.get(url) + resp = requests.get(url, timeout=GRAPHITE_DOWNLOAD_TIMEOUT) if not resp.ok: log.warn( "Graph download failed with error %s %s: %s", @@ -313,7 +318,7 @@ class PCP(Task): try: self.graphite.download_graphs() self.graphite.write_html(mode='static') - except requests.ConnectionError: + except (requests.ConnectionError, requests.ReadTimeout): log.exception("Downloading graphs failed!") self.graphite.write_html() if self.fetch_archives: -- 2.39.5