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 266146 103c7e2422c7
parent 266145 772bcce648ac
child 266147 8b8bd757099b
push id4766
push userryanvm@gmail.com
push date2015-06-01 16:39 +0000
treeherdermozilla-beta@a2f619521d74 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, NPOTB
bugs1165347
milestone39.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),