Skip to content

Commit

Permalink
fetch_repo(): Call rmtree() when all attempts fail
Browse files Browse the repository at this point in the history
Signed-off-by: Zack Cerza <zack@redhat.com>
  • Loading branch information
zmc committed Nov 17, 2015
1 parent dc0b650 commit a604c67
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 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 @@ -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

0 comments on commit a604c67

Please sign in to comment.