aboutsummaryrefslogtreecommitdiff
path: root/kolla/cmd
diff options
context:
space:
mode:
authorVikram Hosakote <vhosakot@cisco.com>2016-02-23 21:04:04 +0000
committerVikram Hosakote <vhosakot@cisco.com>2016-02-28 00:54:47 +0000
commit320c1f92724d6c7bce45398dd783c4334969d23d (patch)
tree36285aba495642f437eadc936cff1f38f2e02041 /kolla/cmd
parentc81097df8b0525bcff9df875f38bbfe2ab83be3f (diff)
downloadkolla-320c1f92724d6c7bce45398dd783c4334969d23d.tar.gz
kolla-320c1f92724d6c7bce45398dd783c4334969d23d.zip
Add timeout to requests.get() in kolla/cmd/build.py
When kolla-build is running, if there are network issues or if the source's location (like http://tarballs.openstack.org) fails to respond due to high number of concurrent requests, kolla-build just hangs/blocks indefinitely. This patch set resolves this issue by adding a timeout of 120 seconds for requests.get() in kolla/cmd/build.py, adds a unit test for it in kolla/tests/test_build.py and also the "timeout" argument in kolla/common/config.py. Change-Id: I7c8745a20b9bd1c3f5d6a55c72a794f16fd7e513 Closes-Bug: #1548614
Diffstat (limited to 'kolla/cmd')
-rwxr-xr-xkolla/cmd/build.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/kolla/cmd/build.py b/kolla/cmd/build.py
index dcbef7718..42eaa3011 100755
--- a/kolla/cmd/build.py
+++ b/kolla/cmd/build.py
@@ -164,7 +164,14 @@ class WorkerThread(threading.Thread):
if source.get('type') == 'url':
LOG.debug("%s:Getting archive from %s", image['name'],
source['source'])
- r = requests.get(source['source'])
+ try:
+ r = requests.get(source['source'], timeout=self.conf.timeout)
+ except requests_exc.Timeout:
+ LOG.exception('Request timed out while getting archive'
+ ' from %s', source['source'])
+ image['status'] = "error"
+ image['logs'] = str()
+ return
if r.status_code == 200:
with open(dest_archive, 'wb') as f: