Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be more tolerant of GitErrors in repo_utils #708

Merged
merged 2 commits into from Nov 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 16 additions & 13 deletions teuthology/repo_utils.py
Expand Up @@ -6,7 +6,7 @@
import time

from .config import config
from .contextutil import safe_while
from .contextutil import safe_while, MaxWhileTries
from .exceptions import BootstrapError, BranchNotFoundError, GitError

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -39,7 +39,7 @@ def enforce_repo_state(repo_url, dest_path, branch, remove_on_error=True):

reset_repo(repo_url, dest_path, branch)
# remove_pyc_files(dest_path)
except (BranchNotFoundError, GitError):
except BranchNotFoundError:
if remove_on_error:
shutil.rmtree(dest_path, ignore_errors=True)
raise
Expand Down Expand Up @@ -178,17 +178,20 @@ def fetch_repo(url, branch, bootstrap=None, lock=True):
lock_path = dest_path.rstrip('/') + '.lock'
with FileLock(lock_path, noop=not lock):
with safe_while(sleep=10, tries=60) as proceed:
while proceed():
try:
enforce_repo_state(url, dest_path,
branch)
if bootstrap:
bootstrap(dest_path)
break
except GitError:
log.exception("Git error encountered; retrying")
except BootstrapError:
log.exception("Bootstrap error encountered; retrying")
try:
while proceed():
try:
enforce_repo_state(url, dest_path, branch)
if bootstrap:
bootstrap(dest_path)
break
except GitError:
log.exception("Git error encountered; retrying")
except BootstrapError:
log.exception("Bootstrap error encountered; retrying")
except MaxWhileTries:
shutil.rmtree(dest_path, ignore_errors=True)
raise
return dest_path


Expand Down