Switch bot_update to use exponential backoff on clone

R=iannucci@chromium.org
BUG=472386

Review-Url: https://codereview.chromium.org/2324073002
changes/18/399118/1
agable 9 years ago committed by Commit bot
parent 3dd7436899
commit c958da4979

@ -470,10 +470,11 @@ def git_checkout(solutions, revisions, shallow, refs, git_cache_dir):
raise Exception('%s exists after cache unlock' % filename) raise Exception('%s exists after cache unlock' % filename)
first_solution = True first_solution = True
for sln in solutions: for sln in solutions:
# This is so we can loop back and try again if we need to wait for the # Just in case we're hitting a different git server than the one from
# git mirrors to update from SVN. # which the target revision was polled, we retry some.
done = False done = False
tries_left = 60 deadline = time.time() + 60 # One minute (5 tries with exp. backoff).
tries = 0
while not done: while not done:
name = sln['name'] name = sln['name']
url = sln['url'] url = sln['url']
@ -509,14 +510,18 @@ def git_checkout(solutions, revisions, shallow, refs, git_cache_dir):
done = True done = True
except SubprocessFailed as e: except SubprocessFailed as e:
# Exited abnormally, theres probably something wrong. # Exited abnormally, theres probably something wrong.
# Lets wipe the checkout and try again. print 'Something failed: %s.' % str(e)
tries_left -= 1
if tries_left > 0: if time.time() > deadline:
print 'Something failed: %s.' % str(e) overrun = time.time() - deadline
print 'waiting 5 seconds and trying again...' print 'Ran %s seconds past deadline. Aborting.' % overrun
time.sleep(5)
else:
raise raise
# Lets wipe the checkout and try again.
tries += 1
sleep_secs = 2**tries
print 'waiting %s seconds and trying again...' % sleep_secs
time.sleep(sleep_secs)
remove(sln_dir) remove(sln_dir)
git('clean', '-dff', cwd=sln_dir) git('clean', '-dff', cwd=sln_dir)

Loading…
Cancel
Save