Merge lp:~le-chi-thu/lava-dispatcher/fix-download-result-fail into lp:lava-dispatcher

Proposed by Le Chi Thu
Status: Merged
Merged at revision: 206
Proposed branch: lp:~le-chi-thu/lava-dispatcher/fix-download-result-fail
Merge into: lp:lava-dispatcher
Diff against target: 61 lines (+17/-20)
2 files modified
lava_dispatcher/client/master.py (+16/-19)
lava_dispatcher/utils.py (+1/-1)
To merge this branch: bzr merge lp:~le-chi-thu/lava-dispatcher/fix-download-result-fail
Reviewer Review Type Date Requested Status
Paul Larson (community) Approve
Review via email: mp+90248@code.launchpad.net

Description of the change

Add retry when download result tarball failed.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_dispatcher/client/master.py'
2--- lava_dispatcher/client/master.py 2012-01-19 09:40:30 +0000
3+++ lava_dispatcher/client/master.py 2012-01-26 10:17:24 +0000
4@@ -485,29 +485,26 @@
5 os.chmod(tarball_dir, 0755)
6
7 # download test result with a retry mechanism
8- # set retry timeout to 2mins
9+ # set retry timeout to 5 mins
10 logging.info("About to download the result tarball to host")
11 now = time.time()
12- timeout = 120
13+ timeout = 300
14 tries = 0
15- try:
16- while time.time() < now + timeout:
17- try:
18- result_path = download(
19- result_tarball, tarball_dir,
20- verbose_failure=tries==0)
21- except RuntimeError:
22- tries += 1
23- if time.time() >= now + timeout:
24- logging.exception("download failed")
25- raise
26- except:
27- logging.warning(traceback.format_exc())
28- err_msg = err_msg + " Can't retrieve test case results."
29- logging.warning(err_msg)
30- return 'fail', err_msg, None
31
32- return 'pass', None, result_path
33+ while True:
34+ try:
35+ result_path = download(
36+ result_tarball, tarball_dir,False)
37+ return 'pass', None, result_path
38+ except RuntimeError:
39+ tries += 1
40+ if time.time() >= now + timeout:
41+ err_msg = "download '%s' failed. Nr tries = %s" %(result_tarball,tries)
42+ logging.error(err_msg)
43+ return 'fail', err_msg, None
44+ else:
45+ logging.info("Sleep one minute and retry (%d)"%tries)
46+ time.sleep(60)
47 finally:
48 session.run('kill %1')
49 session.run('')
50
51=== modified file 'lava_dispatcher/utils.py'
52--- lava_dispatcher/utils.py 2012-01-23 21:32:05 +0000
53+++ lava_dispatcher/utils.py 2012-01-26 10:17:24 +0000
54@@ -40,7 +40,7 @@
55 response.close()
56 except:
57 if verbose_failure:
58- logging.exception("download failed")
59+ logging.exception("download '%s' failed" % url)
60 raise RuntimeError("Could not retrieve %s" % url)
61 return filename
62

Subscribers

People subscribed via source and target branches