libdot: fetch: increase retry count Currently we retry 4 times (so 5 attempts total). Since we backoff by x2 each time, that means our attempt window is <20 seconds before we give up (1 + 2 + 4 + 8 = 15 seconds, plus network delays). Increase this to 7 retries (so 8 attempts total) which stretches us out to over 2 minutes in total. If the server/network is having trouble, then this is still reasonable. Change-Id: I0a84a02a4414181534d76ca5c5de40b26df4e29f Reviewed-on: https://chromium-review.googlesource.com/c/apps/libapps/+/7731981 Reviewed-by: Joel Hockey <joelhockey@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/libdot/bin/libdot.py b/libdot/bin/libdot.py index f12f40a..a45f347 100644 --- a/libdot/bin/libdot.py +++ b/libdot/bin/libdot.py
@@ -561,7 +561,8 @@ # This seems to be good enough for our needs. tmpfile = output if stream else output + ".tmp" backoff = 1 - for attempt in range(0, 5): + MAX_ATTEMPTS = 8 + for attempt in range(1, MAX_ATTEMPTS + 1): try: with open(tmpfile, "wb") as outfp: fetch_data( @@ -591,12 +592,14 @@ sys.exit(1) logging.warning("Download failed: %s", e) - if attempt < 4: + if attempt < MAX_ATTEMPTS: logging.warning("Will retry after sleeping %s seconds", backoff) time.sleep(backoff) backoff *= 2 else: - logging.error("Unabled to download; giving up") + logging.error( + "Unabled to download after %i attempts; giving up", MAX_ATTEMPTS + ) if not stream: unlink(tmpfile) sys.exit(1)