Bug 1165347 - Use retries for symbol uploads. r=gps, a=NPOTB
authorTed Mielczarek <ted@mielczarek.org>
Fri, 15 May 2015 13:48:16 -0400
changeset 201211 b585afd5db9316c897ca3377588f4b8b7a89f7b0
parent 201210 765a5c6b1f739f41a1e9b98cf67b0bfb540af269
child 201212 882d5e18eef435ca158fe906619130ad2c5a068b
push id280
push userryanvm@gmail.com
push dateThu, 04 Jun 2015 20:27:19 +0000
treeherdermozilla-esr31@917d8e07d42b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, NPOTB
bugs1165347
milestone31.7.0
Bug 1165347 - Use retries for symbol uploads. r=gps, a=NPOTB
toolkit/crashreporter/tools/upload_symbols.py
--- a/toolkit/crashreporter/tools/upload_symbols.py
+++ b/toolkit/crashreporter/tools/upload_symbols.py
@@ -10,16 +10,17 @@
 # Using this script requires you to have generated an authentication
 # token in the crash-stats web interface. You must put the token in a file
 # and set SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE to the path to the file in
 # the mozconfig you're using.
 
 from __future__ import print_function
 
 import os
+import redo
 import requests
 import sys
 
 from buildconfig import substs
 
 url = 'https://crash-stats.mozilla.com/symbols/upload'
 
 def main():
@@ -41,23 +42,25 @@ def main():
     if not os.path.isfile(token_file):
         print('Error: SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE "{0}" does not exist!'.format(token_file), file=sys.stderr)
         return 1
     auth_token = open(token_file, 'r').read().strip()
 
     print('Uploading symbol file "{0}" to "{1}"...'.format(sys.argv[1], url))
 
     try:
-        r = requests.post(
-            url,
-            files={'symbols.zip': open(sys.argv[1], 'rb')},
-            headers={'Auth-Token': auth_token},
-            allow_redirects=False,
-            timeout=120,
-        )
+        with redo.retrying(requests.post,
+                           cleanup=lambda: print('Retrying...'),
+                           retry_exceptions=(requests.exceptions.RequestException,)) as post:
+            r = post(
+                url,
+                files={'symbols.zip': open(sys.argv[1], 'rb')},
+                headers={'Auth-Token': auth_token},
+                allow_redirects=False,
+                timeout=120)
     except requests.exceptions.RequestException as e:
         print('Error: {0}'.format(e))
         return 1
 
     if r.status_code >= 200 and r.status_code < 300:
         print('Uploaded successfully!')
     elif r.status_code < 400:
         print('Error: bad auth token? ({0})'.format(r.status_code),