Add retries to pfq push.

Change-Id: Ie4632acf22bedb0c94de0cb3fe67b549fc2d0871

BUG=chromium-os:9323
TEST=Ran it and inserted exception for push_try < 3 and
mocked out push.

Review URL: http://codereview.chromium.org/5142003
This commit is contained in:
Chris Sosa 2010-11-17 17:48:26 -08:00
parent a436eb8ef6
commit 684d5dbccf

View File

@ -215,6 +215,7 @@ def _PushChange():
Raises: Raises:
OSError: Error occurred while pushing. OSError: Error occurred while pushing.
""" """
num_retries = 5
# TODO(sosa) - Add logic for buildbot to check whether other slaves have # TODO(sosa) - Add logic for buildbot to check whether other slaves have
# completed and push this change only if they have. # completed and push this change only if they have.
@ -229,6 +230,8 @@ def _PushChange():
gflags.FLAGS.tracking_branch + '..') gflags.FLAGS.tracking_branch + '..')
description = 'Marking set of ebuilds as stable\n\n%s' % description description = 'Marking set of ebuilds as stable\n\n%s' % description
merge_branch_name = 'merge_branch' merge_branch_name = 'merge_branch'
for push_try in range(num_retries + 1):
try:
_SimpleRunCommand('git remote update') _SimpleRunCommand('git remote update')
merge_branch = _GitBranch(merge_branch_name) merge_branch = _GitBranch(merge_branch_name)
merge_branch.CreateBranch() merge_branch.CreateBranch()
@ -239,6 +242,13 @@ def _PushChange():
# Ugh. There has got to be an easier way to push to a tracking branch # Ugh. There has got to be an easier way to push to a tracking branch
_SimpleRunCommand('git config push.default tracking') _SimpleRunCommand('git config push.default tracking')
_SimpleRunCommand('git push') _SimpleRunCommand('git push')
break
except:
if push_try < num_retries:
Warning('Failed to push change, performing retry (%s/%s)' % (
push_try + 1, num_retries))
else:
raise
def _SimpleRunCommand(command): def _SimpleRunCommand(command):