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
=== modified file 'lava_dispatcher/client/master.py'
--- lava_dispatcher/client/master.py 2012-01-19 09:40:30 +0000
+++ lava_dispatcher/client/master.py 2012-01-26 10:17:24 +0000
@@ -485,29 +485,26 @@
485 os.chmod(tarball_dir, 0755)485 os.chmod(tarball_dir, 0755)
486486
487 # download test result with a retry mechanism487 # download test result with a retry mechanism
488 # set retry timeout to 2mins488 # set retry timeout to 5 mins
489 logging.info("About to download the result tarball to host")489 logging.info("About to download the result tarball to host")
490 now = time.time()490 now = time.time()
491 timeout = 120491 timeout = 300
492 tries = 0492 tries = 0
493 try:
494 while time.time() < now + timeout:
495 try:
496 result_path = download(
497 result_tarball, tarball_dir,
498 verbose_failure=tries==0)
499 except RuntimeError:
500 tries += 1
501 if time.time() >= now + timeout:
502 logging.exception("download failed")
503 raise
504 except:
505 logging.warning(traceback.format_exc())
506 err_msg = err_msg + " Can't retrieve test case results."
507 logging.warning(err_msg)
508 return 'fail', err_msg, None
509493
510 return 'pass', None, result_path494 while True:
495 try:
496 result_path = download(
497 result_tarball, tarball_dir,False)
498 return 'pass', None, result_path
499 except RuntimeError:
500 tries += 1
501 if time.time() >= now + timeout:
502 err_msg = "download '%s' failed. Nr tries = %s" %(result_tarball,tries)
503 logging.error(err_msg)
504 return 'fail', err_msg, None
505 else:
506 logging.info("Sleep one minute and retry (%d)"%tries)
507 time.sleep(60)
511 finally:508 finally:
512 session.run('kill %1')509 session.run('kill %1')
513 session.run('')510 session.run('')
514511
=== modified file 'lava_dispatcher/utils.py'
--- lava_dispatcher/utils.py 2012-01-23 21:32:05 +0000
+++ lava_dispatcher/utils.py 2012-01-26 10:17:24 +0000
@@ -40,7 +40,7 @@
40 response.close()40 response.close()
41 except:41 except:
42 if verbose_failure:42 if verbose_failure:
43 logging.exception("download failed")43 logging.exception("download '%s' failed" % url)
44 raise RuntimeError("Could not retrieve %s" % url)44 raise RuntimeError("Could not retrieve %s" % url)
45 return filename45 return filename
4646

Subscribers

People subscribed via source and target branches