diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 206: retry until timeout for getting results

Message ID 20120127032516.12733.64574.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Paul Larson Jan. 27, 2012, 3:25 a.m. UTC
Merge authors:
  Le Chi Thu le.chi.thu@linaro.org <le.chi.thu@linaro.org>
Related merge proposals:
  https://code.launchpad.net/~le-chi-thu/lava-dispatcher/fix-download-result-fail/+merge/90248
  proposed by: Le Chi Thu (le-chi-thu)
  review: Approve - Paul Larson (pwlars)
------------------------------------------------------------
revno: 206 [merge]
committer: Paul Larson <paul.larson@linaro.org>
branch nick: chithu-logging-and-results-timeout
timestamp: Thu 2012-01-26 21:23:09 -0600
message:
  retry until timeout for getting results
modified:
  lava_dispatcher/client/master.py
  lava_dispatcher/utils.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/client/master.py'
--- lava_dispatcher/client/master.py	2012-01-26 10:14:07 +0000
+++ lava_dispatcher/client/master.py	2012-01-27 03:23:09 +0000
@@ -485,29 +485,28 @@ 
                 os.chmod(tarball_dir, 0755)
 
                 # download test result with a retry mechanism
-                # set retry timeout to 2mins
+                # set retry timeout to 5 mins
                 logging.info("About to download the result tarball to host")
                 now = time.time()
-                timeout = 120
+                timeout = 300
                 tries = 0
-                try:
-                    while time.time() < now + timeout:
-                        try:
-                            result_path = download(
-                                result_tarball, tarball_dir,
-                                verbose_failure=tries==0)
-                        except RuntimeError:
-                            tries += 1
-                            if time.time() >= now + timeout:
-                                logging.exception("download failed")
-                                raise
-                except:
-                    logging.warning(traceback.format_exc())
-                    err_msg = err_msg + " Can't retrieve test case results."
-                    logging.warning(err_msg)
-                    return 'fail', err_msg, None
 
-                return 'pass', None, result_path
+                while True:
+                    try:
+                        result_path = download(
+                            result_tarball, tarball_dir,False)
+                        return 'pass', None, result_path
+                    except RuntimeError:
+                        tries += 1
+                        if time.time() >= now + timeout:
+                            logging.error(
+                                "download '%s' failed. Nr tries = %s" % (
+                                    result_tarball, tries))
+                            return 'fail', err_msg, None
+                        else:
+                            logging.info(
+                                "Sleep one minute and retry (%d)" % tries)
+                            time.sleep(60)
             finally:
                 session.run('kill %1')
                 session.run('')

=== 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:11:27 +0000
@@ -40,7 +40,7 @@ 
         response.close()
     except:
         if verbose_failure:
-            logging.exception("download failed")
+            logging.exception("download '%s' failed" % url)
         raise RuntimeError("Could not retrieve %s" % url)
     return filename