Merge lp:~bjornt/landscape-client/systemerror-no-retry into lp:~landscape/landscape-client/trunk

Proposed by Björn Tillenius
Status: Merged
Approved by: Björn Tillenius
Approved revision: 817
Merged at revision: 817
Proposed branch: lp:~bjornt/landscape-client/systemerror-no-retry
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 82 lines (+30/-13)
2 files modified
landscape/package/facade.py (+6/-2)
landscape/package/tests/test_facade.py (+24/-11)
To merge this branch: bzr merge lp:~bjornt/landscape-client/systemerror-no-retry
Reviewer Review Type Date Requested Status
Chad Smith Approve
Alberto Donato (community) Approve
Review via email: mp+256338@code.launchpad.net

Commit message

Don't retry package operations if a SystemError is raised, since a
SystemError is most likely a permanent error and retrying won't help.

The original patch to retry the operation was to handle lock errors,
which are still properly retried with this branch.

Description of the change

Don't retry package operations if a SystemError is raised, since a
SystemError is most likely a permanent error and retrying won't help.

The original patch to retry the operation was to handle lock errors,
which are properly retried with this branch.

I tested that retrying lock errors still works in both trusty and lucid.

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) wrote :

nice fix, +1

One nitpick inline

review: Approve
Revision history for this message
Adam Collard (adam-collard) :
Revision history for this message
Chad Smith (chad.smith) wrote :

+1 on this change. I think at that time of lp:1177419 we had an imperfect understanding about where apt package errors could come from and just added a blanket retry to catch those cases.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/package/facade.py'
2--- landscape/package/facade.py 2014-09-26 08:21:06 +0000
3+++ landscape/package/facade.py 2015-04-15 15:06:54 +0000
4@@ -675,12 +675,16 @@
5 install_progress=install_progress)
6 if not install_progress.dpkg_exited:
7 raise SystemError("dpkg didn't exit cleanly.")
8- except (apt.cache.LockFailedException, SystemError), error:
9+ except (apt.cache.LockFailedException, SystemError), exception:
10 result_text = (fetch_output.getvalue()
11 + read_file(install_output_path))
12- error = TransactionError(error.args[0] +
13+ error = TransactionError(exception.args[0] +
14 "\n\nPackage operation log:\n" +
15 result_text)
16+ if isinstance(exception, SystemError):
17+ # No need to retry SystemError, since it's most
18+ # likely a permanent error.
19+ break
20 else:
21 result_text = (fetch_output.getvalue()
22 + read_file(install_output_path))
23
24=== modified file 'landscape/package/tests/test_facade.py'
25--- landscape/package/tests/test_facade.py 2014-12-09 07:54:03 +0000
26+++ landscape/package/tests/test_facade.py 2015-04-15 15:06:54 +0000
27@@ -1065,7 +1065,7 @@
28 "Stderr output", "Stdout output again"],
29 output)
30
31- def _test_retry_changes(self, error_type):
32+ def test_retry_changes_lock_failed(self):
33 """
34 Test that changes are retried with the given exception type.
35 """
36@@ -1080,7 +1080,7 @@
37 def commit1(fetch_progress, install_progress):
38 self.facade._cache.commit = commit2
39 os.write(2, "bad stuff!\n")
40- raise error_type("Oops")
41+ raise LockFailedException("Oops")
42
43 def commit2(fetch_progress, install_progress):
44 install_progress.dpkg_exited = True
45@@ -1095,15 +1095,28 @@
46
47 def test_retry_changes_system_error(self):
48 """
49- Changes are retried in the event of a SystemError.
50- """
51- self._test_retry_changes(SystemError)
52-
53- def test_retry_changes_lock_failed(self):
54- """
55- Changes are retried in the event of a L{LockFailedException}.
56- """
57- self._test_retry_changes(LockFailedException)
58+ Changes are not retried in the event of a SystemError, since
59+ it's most likely a permanent error.
60+ """
61+ self.facade.max_dpkg_retries = 1
62+ deb_dir = self.makeDir()
63+ self._add_package_to_deb_dir(deb_dir, "foo")
64+ self.facade.add_channel_apt_deb("file://%s" % deb_dir, "./")
65+ self.facade.reload_channels()
66+ [foo] = self.facade.get_packages_by_name("foo")
67+ self.facade.mark_install(foo)
68+
69+ def commit1(fetch_progress, install_progress):
70+ self.facade._cache.commit = commit2
71+ os.write(2, "bad stuff!\n")
72+ raise SystemError("Oops")
73+
74+ def commit2(fetch_progress, install_progress):
75+ install_progress.dpkg_exited = True
76+ os.write(1, "good stuff!")
77+
78+ self.facade._cache.commit = commit1
79+ self.assertRaises(TransactionError, self.facade.perform_changes)
80
81 def test_perform_changes_dpkg_error_real(self):
82 """

Subscribers

People subscribed via source and target branches

to all changes: