libkas: Terminate kas on _repo_fetch_async errors
This behavior got lost through 0bdd7a8d52
. Specifically, errors during
git clone no longer shut down kas. Fix this by reporting back an error
code from _repo_fetch_async and terminate in repos_fetch if it's
non-zero.
Drop the return value of repos_fetch - no caller expects any.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
9f4af22ac6
commit
264be71ebe
@ -157,7 +157,7 @@ def _repo_fetch_async(config, repo):
|
|||||||
Start asynchronous repository fetch.
|
Start asynchronous repository fetch.
|
||||||
"""
|
"""
|
||||||
if repo.git_operation_disabled:
|
if repo.git_operation_disabled:
|
||||||
return
|
return 0
|
||||||
|
|
||||||
if not os.path.exists(repo.path):
|
if not os.path.exists(repo.path):
|
||||||
os.makedirs(os.path.dirname(repo.path), exist_ok=True)
|
os.makedirs(os.path.dirname(repo.path), exist_ok=True)
|
||||||
@ -173,7 +173,7 @@ def _repo_fetch_async(config, repo):
|
|||||||
cwd=config.kas_work_dir)
|
cwd=config.kas_work_dir)
|
||||||
if retc == 0:
|
if retc == 0:
|
||||||
logging.info('Repository %s cloned', repo.name)
|
logging.info('Repository %s cloned', repo.name)
|
||||||
return
|
return retc
|
||||||
|
|
||||||
# Does refspec exist in the current repository?
|
# Does refspec exist in the current repository?
|
||||||
(retc, output) = yield from run_cmd_async(['/usr/bin/git',
|
(retc, output) = yield from run_cmd_async(['/usr/bin/git',
|
||||||
@ -186,7 +186,7 @@ def _repo_fetch_async(config, repo):
|
|||||||
if retc == 0:
|
if retc == 0:
|
||||||
logging.info('Repository %s already contains %s as %s',
|
logging.info('Repository %s already contains %s as %s',
|
||||||
repo.name, repo.refspec, output.strip())
|
repo.name, repo.refspec, output.strip())
|
||||||
return
|
return retc
|
||||||
|
|
||||||
# No it is missing, try to fetch
|
# No it is missing, try to fetch
|
||||||
(retc, output) = yield from run_cmd_async(['/usr/bin/git',
|
(retc, output) = yield from run_cmd_async(['/usr/bin/git',
|
||||||
@ -199,18 +199,27 @@ def _repo_fetch_async(config, repo):
|
|||||||
repo.name, output)
|
repo.name, output)
|
||||||
else:
|
else:
|
||||||
logging.info('Repository %s updated', repo.name)
|
logging.info('Repository %s updated', repo.name)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def repos_fetch(config, repos):
|
def repos_fetch(config, repos):
|
||||||
"""
|
"""
|
||||||
Fetches the list of repositories to the kas_work_dir.
|
Fetches the list of repositories to the kas_work_dir.
|
||||||
"""
|
"""
|
||||||
cmds = []
|
tasks = []
|
||||||
for repo in repos:
|
for repo in repos:
|
||||||
cmds.append(_repo_fetch_async(config, repo))
|
if hasattr(asyncio, 'ensure_future'):
|
||||||
|
task = asyncio.ensure_future(_repo_fetch_async(config, repo))
|
||||||
|
else:
|
||||||
|
task = asyncio.async(_repo_fetch_async(config, repo))
|
||||||
|
tasks.append(task)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
return loop.run_until_complete(asyncio.wait(cmds))
|
loop.run_until_complete(asyncio.wait(tasks))
|
||||||
|
|
||||||
|
for task in tasks:
|
||||||
|
if task.result():
|
||||||
|
sys.exit(task.result())
|
||||||
|
|
||||||
|
|
||||||
def repo_checkout(config, repo):
|
def repo_checkout(config, repo):
|
||||||
|
Loading…
Reference in New Issue
Block a user