Merge ~xnox/launchpad:copy-signing-bool into launchpad:master

Proposed by Dimitri John Ledkov
Status: Needs review
Proposed branch: ~xnox/launchpad:copy-signing-bool
Merge into: launchpad:master
Diff against target: 137 lines (+41/-2)
5 files modified
lib/lp/archivepublisher/scripts/publish_ftpmaster.py (+3/-1)
lib/lp/soyuz/scripts/custom_uploads_copier.py (+4/-0)
lib/lp/soyuz/scripts/initialize_distroseries.py (+1/-0)
lib/lp/soyuz/scripts/packagecopier.py (+11/-1)
lib/lp/soyuz/scripts/tests/test_custom_uploads_copier.py (+22/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Needs Information
Ubuntu Package Archive Administrators Pending
Review via email: mp+436161@code.launchpad.net

Commit message

custom_uploads_copier.py: Support excluding signing

Add support in custom_uploads_copier to skip copying signing (uefi & signing).

Hook into initialise_distroseries with packagecopier to exclude copying signing. Not sure if this codepath is actually ever used.

Hook into publish_ftpmaster to exclude signing upon preparing to publish fresh series for the first time.

This patch by-itself doesn't expose similar functionality to the `copy-package` exported API, but it will help to implement that later on as well.

Note I only did checks with pre-commit, so unittests were not run, and I didn't do a deploy of development launchpad to test new series init to see if this does what I am intending for it to do.

To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

I was expecting for some archive publishing tests to fail, upon asserting that singing tarballs did not get copied up upon distro series init. But out of the sets of tests that I run, none failed. Maybe this is tested somewhere else, or hasn't been asserted before.

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

My biggest concern here is that the selection of custom upload types to exclude seems quite arbitrary just from looking at the code here, and it's not going to be obvious to future developers what overall properties of the system they need to maintain. At the moment I'm not even sure I understand the rationale well enough to be clear on whether this is the best approach.

Could you please add some commentary somewhere (in the actual code, not just in supporting material such as commit messages or merge proposal conversations) that explains the "why" of this change, as well as the "what"?

review: Needs Information
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

I agree reading the diff it is not obvious, and it is very subtle as to what & why is being changed. In the code-paths that rarely anyone uses or changes. As this is literary only twice a year operation.

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

Yep, that's exactly why we need it to be clearly spelled out, if even I don't quite understand it :-)

Unmerged commits

ef88fc0... by Dimitri John Ledkov

custom_uploads_copier.py: Support excluding signing

Add support in custom_uploads_copier to skip copying signing (uefi &
signing).

Hook into initialise_distroseries with packagecopier to exclude
copying signing. Not sure if this codepath is actually ever used.

Hook into publish_ftpmaster to exclude signing upon preparing to
publish fresh series for the first time.

Signed-off-by: Dimitri John Ledkov <email address hidden>

Succeeded
[SUCCEEDED] docs:0 (build)
[SUCCEEDED] lint:0 (build)
[SUCCEEDED] mypy:0 (build)
13 of 3 results

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py
2index ab301a6..0714693 100644
3--- a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py
4+++ b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py
5@@ -616,7 +616,9 @@ class PublishFTPMaster(LaunchpadCronScript):
6 have_fresh_series = True
7 if series.previous_series is not None:
8 copier = CustomUploadsCopier(
9- series, PackagePublishingPocket.RELEASE
10+ series,
11+ PackagePublishingPocket.RELEASE,
12+ include_signing=False,
13 )
14 copier.copy(
15 series.previous_series, PackagePublishingPocket.RELEASE
16diff --git a/lib/lp/soyuz/scripts/custom_uploads_copier.py b/lib/lp/soyuz/scripts/custom_uploads_copier.py
17index 8eae9be..283e933 100644
18--- a/lib/lp/soyuz/scripts/custom_uploads_copier.py
19+++ b/lib/lp/soyuz/scripts/custom_uploads_copier.py
20@@ -49,10 +49,14 @@ class CustomUploadsCopier:
21 target_series,
22 target_pocket=PackagePublishingPocket.RELEASE,
23 target_archive=None,
24+ include_signing=True,
25 ):
26 self.target_series = target_series
27 self.target_pocket = target_pocket
28 self.target_archive = target_archive
29+ if not include_signing:
30+ del self.copyable_types[PackageUploadCustomFormat.UEFI]
31+ del self.copyable_types[PackageUploadCustomFormat.SIGNING]
32
33 def isCopyable(self, upload):
34 """Is `upload` the kind of `PackageUploadCustom` that we can copy?"""
35diff --git a/lib/lp/soyuz/scripts/initialize_distroseries.py b/lib/lp/soyuz/scripts/initialize_distroseries.py
36index 5ffe47d..ffb41cf 100644
37--- a/lib/lp/soyuz/scripts/initialize_distroseries.py
38+++ b/lib/lp/soyuz/scripts/initialize_distroseries.py
39@@ -676,6 +676,7 @@ class InitializeDistroSeries:
40 close_bugs=False,
41 create_dsd_job=False,
42 person=None,
43+ include_signing=False,
44 )
45 )
46 if self.rebuild:
47diff --git a/lib/lp/soyuz/scripts/packagecopier.py b/lib/lp/soyuz/scripts/packagecopier.py
48index 372c52f..dfd5f28 100644
49--- a/lib/lp/soyuz/scripts/packagecopier.py
50+++ b/lib/lp/soyuz/scripts/packagecopier.py
51@@ -581,6 +581,7 @@ def do_copy(
52 phased_update_percentage=None,
53 move=False,
54 logger=None,
55+ include_signing=True,
56 ):
57 """Perform the complete copy of the given sources incrementally.
58
59@@ -633,6 +634,8 @@ def do_copy(
60 :param move: If True, delete the source publication after copying to the
61 destination.
62 :param logger: An optional logger.
63+ :param include_signing: A boolean indicating whether or not to copy
64+ signing custom upload types.
65
66 :raise CannotCopy when one or more copies were not allowed. The error
67 will contain the reason why each copy was denied.
68@@ -741,6 +744,7 @@ def do_copy(
69 phased_update_percentage=phased_update_percentage,
70 move=move,
71 logger=logger,
72+ include_signing=include_signing,
73 )
74 if send_email and sub_copies:
75 mailer = PackageUploadMailer.forAction(
76@@ -790,6 +794,7 @@ def _do_direct_copy(
77 phased_update_percentage=None,
78 move=False,
79 logger=None,
80+ include_signing=True,
81 ):
82 """Copy publishing records to another location.
83
84@@ -825,6 +830,8 @@ def _do_direct_copy(
85 :param move: If True, delete the source publication after copying to the
86 destination.
87 :param logger: An optional logger.
88+ :param include_signing: A boolean indicating whether or not to copy
89+ signing custom upload types.
90
91 :return: a list of `ISourcePackagePublishingHistory` and
92 `BinaryPackagePublishingHistory` corresponding to the copied
93@@ -903,7 +910,10 @@ def _do_direct_copy(
94 # Custom uploads aren't modelled as publication history records, so
95 # we have to send these through the upload queue.
96 custom_copier = CustomUploadsCopier(
97- series, target_pocket=pocket, target_archive=archive
98+ series,
99+ target_pocket=pocket,
100+ target_archive=archive,
101+ include_signing=include_signing,
102 )
103 for custom in custom_files:
104 if custom_copier.isCopyable(custom):
105diff --git a/lib/lp/soyuz/scripts/tests/test_custom_uploads_copier.py b/lib/lp/soyuz/scripts/tests/test_custom_uploads_copier.py
106index af1b325..de21254 100644
107--- a/lib/lp/soyuz/scripts/tests/test_custom_uploads_copier.py
108+++ b/lib/lp/soyuz/scripts/tests/test_custom_uploads_copier.py
109@@ -71,6 +71,28 @@ class TestCustomUploadsCopierLite(TestCaseWithFactory, CommonTestHelpers):
110 [upload.customformat for upload in copied_uploads],
111 )
112
113+ def test_isCopyable_exclude_signing_types(self):
114+ # Same as above, but check that signing types are excluded,
115+ # when copyer is requested to ignore them
116+ uploads = [
117+ FakeUpload(custom_type, None)
118+ for custom_type in PackageUploadCustomFormat.items
119+ ]
120+ copier = CustomUploadsCopier(FakeDistroSeries(), include_signing=False)
121+ copied_uploads = filter(copier.isCopyable, uploads)
122+ self.assertFalse(
123+ PackageUploadCustomFormat.UEFI
124+ in CustomUploadsCopier.copyable_types
125+ )
126+ self.assertFalse(
127+ PackageUploadCustomFormat.SIGNING
128+ in CustomUploadsCopier.copyable_types
129+ )
130+ self.assertContentEqual(
131+ CustomUploadsCopier.copyable_types,
132+ [upload.customformat for upload in copied_uploads],
133+ )
134+
135 def test_getKey_calls_correct_custom_upload_method(self):
136 # getKey calls the getSeriesKey method on the correct custom upload.
137 class FakeCustomUpload:

Subscribers

People subscribed via source and target branches

to status/vote changes: