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

Fail and retry on "Some index files failed to download" #911

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions charmhelpers/fetch/ubuntu.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
])


APT_NO_LOCK = 100 # The return code for "couldn't acquire lock" in APT.
APT_ERROR_CODE = 100 # The return code for APT errors.
CMD_RETRY_DELAY = 10 # Wait 10 seconds between command retries.
CMD_RETRY_COUNT = 10 # Retry a failing fatal command X times.

Expand Down Expand Up @@ -444,6 +444,8 @@ def apt_upgrade(options=None, fatal=False, dist=False):
def apt_update(fatal=False):
"""Update local apt cache."""
cmd = ['apt-get', 'update']
if fatal:
cmd.append("--error-on=any")
_run_apt_command(cmd, fatal)


Expand Down Expand Up @@ -1001,8 +1003,7 @@ def _run_apt_command(cmd, fatal=False, quiet=False):
"""
if fatal:
_run_with_retries(
cmd, retry_exitcodes=(1, APT_NO_LOCK,),
retry_message="Couldn't acquire DPKG lock",
cmd, retry_exitcodes=(1, APT_ERROR_CODE,),
quiet=quiet)
else:
kwargs = {}
Expand Down
2 changes: 1 addition & 1 deletion tests/fetch/test_fetch_ubuntu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ def test_apt_unhold_fatal(self, apt_mark):
def test_apt_update_fatal(self, check_call):
fetch.apt_update(fatal=True)
check_call.assert_called_with(
['apt-get', 'update'],
['apt-get', 'update', '--error-on=any'],
env={})

@patch('subprocess.call')
Expand Down
Loading