A 500 error from gitea can occasionally show up as a project dropping
their devstack plugin (I543faced83a685d48706d004ae49800abfb89dc5).
To avoid noise in the proposal jobs, implement a small retry loop for
500 errors.
Change-Id: Ide23e4de819a2c751d887eeaa7f0b9d0437f8e2c
| ... | ... |
@@ -28,6 +28,9 @@ import logging |
| 28 | 28 |
import json |
| 29 | 29 |
import requests |
| 30 | 30 |
|
| 31 |
+from requests.adapters import HTTPAdapter |
|
| 32 |
+from requests.packages.urllib3.util.retry import Retry |
|
| 33 |
+ |
|
| 31 | 34 |
logging.basicConfig(level=logging.DEBUG) |
| 32 | 35 |
|
| 33 | 36 |
url = 'https://review.opendev.org/projects/' |
| ... | ... |
@@ -63,6 +66,12 @@ projects = sorted(filter(is_in_wanted_namespace, json.loads(r.text[4:]))) |
| 63 | 63 |
logging.debug("Found %d projects" % len(projects))
|
| 64 | 64 |
|
| 65 | 65 |
s = requests.Session() |
| 66 |
+# sometimes gitea gives us a 500 error; retry sanely |
|
| 67 |
+# https://stackoverflow.com/a/35636367 |
|
| 68 |
+retries = Retry(total=3, backoff_factor=1, |
|
| 69 |
+ status_forcelist=[ 500 ]) |
|
| 70 |
+s.mount('https://', HTTPAdapter(max_retries=retries))
|
|
| 71 |
+ |
|
| 66 | 72 |
found_plugins = filter(functools.partial(has_devstack_plugin, s), projects) |
| 67 | 73 |
|
| 68 | 74 |
for project in found_plugins: |