From: John Spray Date: Thu, 19 Jan 2017 13:47:59 +0000 (+0000) Subject: pcp: use a timeout when downloading graphite graphs X-Git-Tag: 1.1.0~472^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=adc1beffd23febfbca02c225c12e5f72ffb58c27;p=teuthology.git pcp: use a timeout when downloading graphite graphs Fixes: http://tracker.ceph.com/issues/18597 Signed-off-by: John Spray --- diff --git a/teuthology/task/pcp.py b/teuthology/task/pcp.py index 6f61311bc..065bde00f 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: