Merge lp:~cjwatson/launchpad/ds-publish-by-hash into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17960
Proposed branch: lp:~cjwatson/launchpad/ds-publish-by-hash
Merge into: lp:launchpad
Prerequisite: lp:~cjwatson/launchpad/archive-file-model
Diff against target: 165 lines (+68/-0)
7 files modified
lib/lp/registry/configure.zcml (+2/-0)
lib/lp/registry/interfaces/distroseries.py (+14/-0)
lib/lp/registry/model/distroseries.py (+20/-0)
lib/lp/registry/stories/webservice/xx-distroseries.txt (+2/-0)
lib/lp/registry/tests/test_distroseries.py (+20/-0)
lib/lp/soyuz/scripts/initialize_distroseries.py (+6/-0)
lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py (+4/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/ds-publish-by-hash
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+289377@code.launchpad.net

Commit message

Add and export DistroSeries.publish_by_hash and DistroSeries.advertise_by_hash.

Description of the change

Add and export DistroSeries.publish_by_hash and DistroSeries.advertise_by_hash. This won't do anything useful until later branches that implement it in archivepublisher, but I'm separating it out to make the branches a more manageable size.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

For testing, do we want a way to force by-hash to be published but leave the Release flag unset? AIUI one can force by-hash in sources.list.

review: Approve (code)
Revision history for this message
Colin Watson (cjwatson) wrote :

Makes sense. I've added advertise_by_hash now as well.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/configure.zcml'
2--- lib/lp/registry/configure.zcml 2016-02-28 19:13:17 +0000
3+++ lib/lp/registry/configure.zcml 2016-03-18 15:41:25 +0000
4@@ -318,6 +318,8 @@
5 backports_not_automatic
6 include_long_descriptions
7 index_compressors
8+ publish_by_hash
9+ advertise_by_hash
10 inherit_overrides_from_parents"/>
11
12 <!-- NB: check with SABDFL before modifying these, there is potential to
13
14=== modified file 'lib/lp/registry/interfaces/distroseries.py'
15--- lib/lp/registry/interfaces/distroseries.py 2016-02-05 20:28:29 +0000
16+++ lib/lp/registry/interfaces/distroseries.py 2016-03-18 15:41:25 +0000
17@@ -387,6 +387,20 @@
18 A list of compression types to use for published index files
19 (Packages, Sources, etc.).""")))
20
21+ publish_by_hash = exported(Bool(
22+ title=_("Publish by-hash directories"), required=True,
23+ description=_("""
24+ Publish archive index files in by-hash directories so that apt
25+ can retrieve them based on their hash, avoiding race conditions
26+ between InRelease and other files during mirror updates.""")))
27+
28+ advertise_by_hash = exported(Bool(
29+ title=_("Advertise by-hash directories"), required=True,
30+ description=_("""
31+ Advertise by-hash directories with a flag in the Release file so
32+ that apt uses them by default. Only effective if
33+ publish_by_hash is also set.""")))
34+
35 inherit_overrides_from_parents = Bool(
36 title=_("Inherit overrides from parents"),
37 readonly=False, required=True)
38
39=== modified file 'lib/lp/registry/model/distroseries.py'
40--- lib/lp/registry/model/distroseries.py 2016-03-04 14:18:23 +0000
41+++ lib/lp/registry/model/distroseries.py 2016-03-18 15:41:25 +0000
42@@ -276,6 +276,8 @@
43 "index_compressors": [
44 compressor.title
45 for compressor in DEFAULT_INDEX_COMPRESSORS],
46+ "publish_by_hash": False,
47+ "advertise_by_hash": False,
48 }
49 super(DistroSeries, self).__init__(*args, **kwargs)
50
51@@ -841,6 +843,24 @@
52 self.publishing_options["index_compressors"] = [
53 compressor.title for compressor in value]
54
55+ @property
56+ def publish_by_hash(self):
57+ return self.publishing_options.get("publish_by_hash", False)
58+
59+ @publish_by_hash.setter
60+ def publish_by_hash(self, value):
61+ assert isinstance(value, bool)
62+ self.publishing_options["publish_by_hash"] = value
63+
64+ @property
65+ def advertise_by_hash(self):
66+ return self.publishing_options.get("advertise_by_hash", False)
67+
68+ @advertise_by_hash.setter
69+ def advertise_by_hash(self, value):
70+ assert isinstance(value, bool)
71+ self.publishing_options["advertise_by_hash"] = value
72+
73 def _customizeSearchParams(self, search_params):
74 """Customize `search_params` for this distribution series."""
75 search_params.setDistroSeries(self)
76
77=== modified file 'lib/lp/registry/stories/webservice/xx-distroseries.txt'
78--- lib/lp/registry/stories/webservice/xx-distroseries.txt 2016-02-08 15:09:00 +0000
79+++ lib/lp/registry/stories/webservice/xx-distroseries.txt 2016-03-18 15:41:25 +0000
80@@ -60,6 +60,7 @@
81 active: True
82 active_milestones_collection_link:
83 u'http://.../ubuntu/hoary/active_milestones'
84+ advertise_by_hash: False
85 all_milestones_collection_link: u'http://.../ubuntu/hoary/all_milestones'
86 architectures_collection_link: u'http://.../ubuntu/hoary/architectures'
87 bug_reported_acknowledgement: None
88@@ -83,6 +84,7 @@
89 official_bug_tags: []
90 owner_link: u'http://.../~ubuntu-team'
91 parent_series_link: u'http://.../ubuntu/warty'
92+ publish_by_hash: False
93 registrant_link: u'http://.../~mark'
94 resource_type_link: ...
95 self_link: u'http://.../ubuntu/hoary'
96
97=== modified file 'lib/lp/registry/tests/test_distroseries.py'
98--- lib/lp/registry/tests/test_distroseries.py 2016-02-05 20:28:29 +0000
99+++ lib/lp/registry/tests/test_distroseries.py 2016-03-18 15:41:25 +0000
100@@ -383,6 +383,26 @@
101 self.assertEqual(
102 ["xz"], naked_distroseries.publishing_options["index_compressors"])
103
104+ def test_publish_by_hash(self):
105+ distroseries = self.factory.makeDistroSeries()
106+ self.assertFalse(distroseries.publish_by_hash)
107+ with admin_logged_in():
108+ distroseries.publish_by_hash = True
109+ self.assertTrue(distroseries.publish_by_hash)
110+ naked_distroseries = removeSecurityProxy(distroseries)
111+ self.assertTrue(
112+ naked_distroseries.publishing_options["publish_by_hash"])
113+
114+ def test_advertise_by_hash(self):
115+ distroseries = self.factory.makeDistroSeries()
116+ self.assertFalse(distroseries.advertise_by_hash)
117+ with admin_logged_in():
118+ distroseries.advertise_by_hash = True
119+ self.assertTrue(distroseries.advertise_by_hash)
120+ naked_distroseries = removeSecurityProxy(distroseries)
121+ self.assertTrue(
122+ naked_distroseries.publishing_options["advertise_by_hash"])
123+
124
125 class TestDistroSeriesPackaging(TestCaseWithFactory):
126
127
128=== modified file 'lib/lp/soyuz/scripts/initialize_distroseries.py'
129--- lib/lp/soyuz/scripts/initialize_distroseries.py 2015-05-13 12:40:44 +0000
130+++ lib/lp/soyuz/scripts/initialize_distroseries.py 2016-03-18 15:41:25 +0000
131@@ -375,6 +375,12 @@
132 self.distroseries.include_long_descriptions = any(
133 parent.include_long_descriptions
134 for parent in self.derivation_parents)
135+ self.distroseries.publish_by_hash = any(
136+ parent.publish_by_hash
137+ for parent in self.derivation_parents)
138+ self.distroseries.advertise_by_hash = any(
139+ parent.advertise_by_hash
140+ for parent in self.derivation_parents)
141
142 def _copy_architectures(self):
143 das_filter = ' AND distroseries IN %s ' % (
144
145=== modified file 'lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py'
146--- lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py 2015-04-20 15:59:52 +0000
147+++ lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py 2016-03-18 15:41:25 +0000
148@@ -83,6 +83,8 @@
149 spfss_utility.add(parent, format_selection)
150 parent.backports_not_automatic = True
151 parent.include_long_descriptions = False
152+ parent.publish_by_hash = True
153+ parent.advertise_by_hash = True
154 self._populate_parent(parent, parent_das, packages, pocket)
155 return parent, parent_das
156
157@@ -610,6 +612,8 @@
158 # Other configuration bits are copied too.
159 self.assertTrue(child.backports_not_automatic)
160 self.assertFalse(child.include_long_descriptions)
161+ self.assertTrue(child.publish_by_hash)
162+ self.assertTrue(child.advertise_by_hash)
163
164 def test_initialize(self):
165 # Test a full initialize with no errors.