mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 06:30:19 -07:00
apt: better error msg when update_cache fails (#37410)
This commit is contained in:
parent
6292fe1116
commit
a6d31b6fb1
2 changed files with 27 additions and 3 deletions
|
@ -956,14 +956,15 @@ def main():
|
|||
tdelta = datetime.timedelta(seconds=p['cache_valid_time'])
|
||||
if not mtimestamp + tdelta >= now:
|
||||
# Retry to update the cache up to 3 times
|
||||
err = ''
|
||||
for retry in range(3):
|
||||
try:
|
||||
cache.update()
|
||||
break
|
||||
except apt.cache.FetchFailedException:
|
||||
pass
|
||||
except apt.cache.FetchFailedException as e:
|
||||
err = to_native(e)
|
||||
else:
|
||||
module.fail_json(msg='Failed to update apt cache.')
|
||||
module.fail_json(msg='Failed to update apt cache: %s' % err)
|
||||
cache.open(progress=None)
|
||||
updated_cache = True
|
||||
mtimestamp, updated_cache_time = get_updated_cache_time()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue