Merge lp:~ahasenack/landscape-client/17.03-backports-fix into lp:~landscape/landscape-client/17.03

Proposed by Andreas Hasenack
Status: Merged
Approved by: Andreas Hasenack
Approved revision: 944
Merged at revision: 941
Proposed branch: lp:~ahasenack/landscape-client/17.03-backports-fix
Merge into: lp:~landscape/landscape-client/17.03
Diff against target: 178 lines (+115/-11)
3 files modified
debian/changelog (+8/-11)
landscape/package/reporter.py (+19/-0)
landscape/package/tests/test_reporter.py (+88/-0)
To merge this branch: bzr merge lp:~ahasenack/landscape-client/17.03-backports-fix
Reviewer Review Type Date Requested Status
Landscape Builder test results Approve
Adam Collard (community) Approve
Alberto Donato Approve
Review via email: mp+321115@code.launchpad.net

Commit message

Backport fix for #1668583 (don't report backport packages) from trunk r962.

Description of the change

Backport fix for #1668583 (don't report backport packages) from trunk r962.

We want 17.03 client builds to populate ppa:landscape/landscape-cloud-installer and lds-proposed.

The current LP recipe for builds out of this 17.03 branch is:

# bzr-builder format 0.3 deb-version {debupstream}-0~{revno}
lp:~landscape/landscape-client/17.03

This means that with a plain "17.03" in debian/changelog, we would get a package like this:

17.03-0~941

Which could make one think this is trunk r941 if you just look at that version without the context of which branch it was built from.

Therefore, I also changed the "debupstream" version of the package in debian/changelog so it's clear this is still client r940 from trunk *plus* the r962 fix.

In the end, the recipe will give us a build with a version like this:

17.03~bzr940-0~941

It's still not super clear where this build came from, though. We could use "17.03~release71-0~941" instead perhaps, except there is no release-71 branch for the client.

To post a comment you must log in.
Alberto Donato (ack) wrote :

+1

review: Approve
review: Approve

The attempt to merge lp:~ahasenack/landscape-client/17.03-backports-fix into lp:~landscape/landscape-client/17.03 failed. Below is the output from the failed tests.

make: *** No rule to make target 'ci-check'. Stop.

No approved revision specified.

review: Abstain (executing tests)

Command: TRIAL_ARGS=-j4 make ci-check
Result: Fail
Revno: 944
Branch: lp:~ahasenack/landscape-client/17.03-backports-fix
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3790/

review: Needs Fixing (test results)
review: Abstain (executing tests)

Command: TRIAL_ARGS=-j4 make check
Result: Success
Revno: 944
Branch: lp:~ahasenack/landscape-client/17.03-backports-fix
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3791/

review: Approve (test results)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2017-03-02 09:59:16 +0000
3+++ debian/changelog 2017-03-27 20:35:37 +0000
4@@ -1,14 +1,11 @@
5-landscape-client (17.02-0ubuntu1) UNRELEASED; urgency=medium
6-
7- * Bump version
8-
9- -- Alberto Donato <alberto.donato@canonical.com> Thu, 02 Mar 2017 10:51:32 +0100
10-
11-landscape-client (17.01-0ubuntu1) UNRELEASED; urgency=medium
12-
13- * New trunk build
14-
15- -- Andreas Hasenack <andreas@canonical.com> Fri, 05 Aug 2016 10:29:28 -0300
16+landscape-client (17.03~bzr940-0ubuntu1) UNRELEASED; urgency=medium
17+
18+ * Client 17.03~bzr940: branched off trunk r940
19+ * Don't report packages that are coming from backports, so that Landscape
20+ doesn't try to upgrade to versions of packages that are in backports.
21+ Backported from trunk's r962. (LP: #1668583)
22+
23+ -- Andreas Hasenack <andreas@canonical.com> Mon, 27 Mar 2017 17:17:10 -0300
24
25 landscape-client (16.03-0ubuntu1) xenial; urgency=medium
26
27
28=== modified file 'landscape/package/reporter.py'
29--- landscape/package/reporter.py 2016-08-04 16:13:11 +0000
30+++ landscape/package/reporter.py 2017-03-27 20:35:37 +0000
31@@ -13,6 +13,7 @@
32 from landscape.lib.twisted_util import gather_results, spawn_process
33 from landscape.lib.fetch import fetch_async
34 from landscape.lib.fs import touch_file
35+from landscape.lib.lsb_release import parse_lsb_release, LSB_RELEASE_FILENAME
36 from landscape.lib import bpickle
37
38 from landscape.package.taskhandler import (
39@@ -546,8 +547,26 @@
40 current_available = set()
41 current_upgrades = set()
42 current_locked = set()
43+ lsb = parse_lsb_release(LSB_RELEASE_FILENAME)
44+ backports_archive = "{}-backports".format(lsb["code-name"])
45
46 for package in self._facade.get_packages():
47+ # Don't include package versions from the official backports
48+ # archive. The backports archive is enabled by default since
49+ # xenial with a pinning policy of 100. Ideally we would
50+ # support pinning, but we don't yet. In the mean time, we
51+ # ignore backports, so that packages don't get automatically
52+ # upgraded to the backports version.
53+ backport_origins = [
54+ origin for origin in package.origins
55+ if origin.archive == backports_archive]
56+ if backport_origins and (
57+ len(backport_origins) == len(package.origins)):
58+ # Ignore the version if it's only in the official
59+ # backports archive. If it's somewhere else as well,
60+ # e.g. a PPA, we assume it was added manually and the
61+ # user wants to get updates from it.
62+ continue
63 hash = self._facade.get_package_hash(package)
64 id = self._store.get_hash_id(hash)
65 if id is not None:
66
67=== modified file 'landscape/package/tests/test_reporter.py'
68--- landscape/package/tests/test_reporter.py 2016-08-04 16:13:11 +0000
69+++ landscape/package/tests/test_reporter.py 2017-03-27 20:35:37 +0000
70@@ -3,6 +3,7 @@
71 import time
72 import apt_pkg
73 import mock
74+import shutil
75
76 from twisted.internet.defer import Deferred, succeed, fail, inlineCallbacks
77 from twisted.internet import reactor
78@@ -10,6 +11,7 @@
79
80 from landscape.lib.fs import create_file, touch_file
81 from landscape.lib.fetch import FetchError
82+from landscape.lib.lsb_release import parse_lsb_release, LSB_RELEASE_FILENAME
83 from landscape.lib import bpickle
84 from landscape.package.store import (
85 PackageStore, UnknownHashIDRequest, FakePackageStore)
86@@ -923,6 +925,92 @@
87 result = self.reporter.detect_packages_changes()
88 return result.addCallback(got_result)
89
90+ def test_detect_packages_changes_with_backports(self):
91+ """
92+ Package versions coming from backports aren't considered to be
93+ available.
94+
95+ This is because we don't support pinning, and the backports
96+ archive is enabled by default since xenial.
97+ """
98+ message_store = self.broker_service.message_store
99+ message_store.set_accepted_types(["packages"])
100+
101+ lsb = parse_lsb_release(LSB_RELEASE_FILENAME)
102+ release_path = os.path.join(self.repository_dir, "Release")
103+ with open(release_path, "w") as release:
104+ release.write("Suite: {}-backports".format(lsb["code-name"]))
105+
106+ self.store.set_hash_ids({HASH1: 1, HASH2: 2, HASH3: 3})
107+
108+ def got_result(result):
109+ self.assertMessages(message_store.get_pending_messages(), [])
110+
111+ self.assertEqual(sorted(self.store.get_available()), [])
112+
113+ result = self.reporter.detect_packages_changes()
114+ return result.addCallback(got_result)
115+
116+ def test_detect_packages_changes_with_backports_others(self):
117+ """
118+ Packages coming from backport archives that aren't named like
119+ the official backports archive are considered to be available.
120+ """
121+ message_store = self.broker_service.message_store
122+ message_store.set_accepted_types(["packages"])
123+
124+ release_path = os.path.join(self.repository_dir, "Release")
125+ with open(release_path, "w") as release:
126+ release.write("Suite: my-personal-backports")
127+
128+ self.store.set_hash_ids({HASH1: 1, HASH2: 2, HASH3: 3})
129+
130+ def got_result(result):
131+ self.assertMessages(message_store.get_pending_messages(),
132+ [{"type": "packages", "available": [(1, 3)]}])
133+
134+ self.assertEqual(sorted(self.store.get_available()), [1, 2, 3])
135+
136+ result = self.reporter.detect_packages_changes()
137+ return result.addCallback(got_result)
138+
139+ def test_detect_packages_changes_with_backports_both(self):
140+ """
141+ If a package is both in the official backports archive and in
142+ some other archive (e.g. a PPA), the package is considered to be
143+ available.
144+
145+ The reason for this is that if you have enabled a PPA, you most
146+ likely want to get updates from it.
147+ """
148+ message_store = self.broker_service.message_store
149+ message_store.set_accepted_types(["packages"])
150+
151+ temp_dir = self.makeDir()
152+ other_backport_dir = os.path.join(temp_dir, "my-personal-backports")
153+ shutil.copytree(self.repository_dir, other_backport_dir)
154+ os.remove(os.path.join(other_backport_dir, "Packages"))
155+ self.facade.add_channel_deb_dir(other_backport_dir)
156+
157+ lsb = parse_lsb_release(LSB_RELEASE_FILENAME)
158+ official_release_path = os.path.join(self.repository_dir, "Release")
159+ with open(official_release_path, "w") as release:
160+ release.write("Suite: {}-backports".format(lsb["code-name"]))
161+ unofficial_release_path = os.path.join(other_backport_dir, "Release")
162+ with open(unofficial_release_path, "w") as release:
163+ release.write("Suite: my-personal-backports")
164+
165+ self.store.set_hash_ids({HASH1: 1, HASH2: 2, HASH3: 3})
166+
167+ def got_result(result):
168+ self.assertMessages(message_store.get_pending_messages(),
169+ [{"type": "packages", "available": [(1, 3)]}])
170+
171+ self.assertEqual(sorted(self.store.get_available()), [1, 2, 3])
172+
173+ result = self.reporter.detect_packages_changes()
174+ return result.addCallback(got_result)
175+
176 @inlineCallbacks
177 def test_detect_packages_after_tasks(self):
178 """

Subscribers

People subscribed via source and target branches

to all changes: