diff --git a/charmhelpers/fetch/ubuntu.py b/charmhelpers/fetch/ubuntu.py index d0089eb7f..37a6eaa5a 100644 --- a/charmhelpers/fetch/ubuntu.py +++ b/charmhelpers/fetch/ubuntu.py @@ -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. @@ -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) @@ -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 = {} diff --git a/tests/fetch/test_fetch_ubuntu.py b/tests/fetch/test_fetch_ubuntu.py index be5add582..619f045a9 100644 --- a/tests/fetch/test_fetch_ubuntu.py +++ b/tests/fetch/test_fetch_ubuntu.py @@ -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')