From 684d5dbccf1579fe9a3ac299988fcc1c8ed52584 Mon Sep 17 00:00:00 2001 From: Chris Sosa Date: Wed, 17 Nov 2010 17:48:26 -0800 Subject: [PATCH] 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 --- cros_mark_as_stable.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/cros_mark_as_stable.py b/cros_mark_as_stable.py index 5df6a83fef..2425ff2b02 100755 --- a/cros_mark_as_stable.py +++ b/cros_mark_as_stable.py @@ -215,6 +215,7 @@ def _PushChange(): Raises: OSError: Error occurred while pushing. """ + num_retries = 5 # TODO(sosa) - Add logic for buildbot to check whether other slaves have # completed and push this change only if they have. @@ -229,16 +230,25 @@ def _PushChange(): gflags.FLAGS.tracking_branch + '..') description = 'Marking set of ebuilds as stable\n\n%s' % description merge_branch_name = 'merge_branch' - _SimpleRunCommand('git remote update') - merge_branch = _GitBranch(merge_branch_name) - merge_branch.CreateBranch() - if not merge_branch.Exists(): - Die('Unable to create merge branch.') - _SimpleRunCommand('git merge --squash %s' % _STABLE_BRANCH_NAME) - _SimpleRunCommand('git commit -m "%s"' % description) - # Ugh. There has got to be an easier way to push to a tracking branch - _SimpleRunCommand('git config push.default tracking') - _SimpleRunCommand('git push') + for push_try in range(num_retries + 1): + try: + _SimpleRunCommand('git remote update') + merge_branch = _GitBranch(merge_branch_name) + merge_branch.CreateBranch() + if not merge_branch.Exists(): + Die('Unable to create merge branch.') + _SimpleRunCommand('git merge --squash %s' % _STABLE_BRANCH_NAME) + _SimpleRunCommand('git commit -m "%s"' % description) + # Ugh. There has got to be an easier way to push to a tracking branch + _SimpleRunCommand('git config push.default tracking') + _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):