]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
pcp: use a timeout when downloading graphite graphs 1014/head
authorJohn Spray <john.spray@redhat.com>
Thu, 19 Jan 2017 13:47:59 +0000 (13:47 +0000)
committerJohn Spray <john.spray@redhat.com>
Fri, 20 Jan 2017 09:22:20 +0000 (09:22 +0000)
Fixes: http://tracker.ceph.com/issues/18597
Signed-off-by: John Spray <john.spray@redhat.com>
teuthology/task/pcp.py

index 6f61311bc79998a086bd6a82612204bca3ba4c98..065bde00f12fec781f66533d63a89aea73c0a4e4 100644 (file)
@@ -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: