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 238548 15b2ed7108140e2e05ea5fd210ef89d2e736afc8
parent 238547 6212532a6bdb2c9feb644ede1bc7e02a07c172a9
child 238549 19e28150c7d49f534ab357d5372a4f5f18cabf52
push id667
push userryanvm@gmail.com
push dateMon, 01 Jun 2015 19:48:18 +0000
treeherdermozilla-b2g37_v2_2@c163c2a5b921 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, NPOTB
bugs1165347
milestone37.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),