Merge ~ilasc/launchpad:publisher-excludes-conda-source-pkgs into launchpad:master

Proposed by Ioana Lasc
Status: Merged
Approved by: Ioana Lasc
Approved revision: efbf06d37baa7cde6c179dac9593d1ad2d484264
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ilasc/launchpad:publisher-excludes-conda-source-pkgs
Merge into: launchpad:master
Diff against target: 92 lines (+34/-1)
2 files modified
lib/lp/soyuz/model/publishing.py (+13/-0)
lib/lp/soyuz/tests/test_publishing.py (+21/-1)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+432957@code.launchpad.net

Commit message

Publisher skips Conda source packages

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Thanks for tackling this! Looks good with some comments.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/soyuz/model/publishing.py b/lib/lp/soyuz/model/publishing.py
2index b4611ac..1df1fa6 100644
3--- a/lib/lp/soyuz/model/publishing.py
4+++ b/lib/lp/soyuz/model/publishing.py
5@@ -54,6 +54,7 @@ from lp.services.webapp.errorlog import ErrorReportingUtility, ScriptRequest
6 from lp.services.worlddata.model.country import Country
7 from lp.soyuz.adapters.proxiedsourcefiles import ProxiedSourceLibraryFileAlias
8 from lp.soyuz.enums import (
9+ ArchiveRepositoryFormat,
10 BinaryPackageFormat,
11 PackagePublishingPriority,
12 PackagePublishingStatus,
13@@ -67,6 +68,7 @@ from lp.soyuz.interfaces.component import IComponentSet
14 from lp.soyuz.interfaces.distributionjob import (
15 IDistroSeriesDifferenceJobSource,
16 )
17+from lp.soyuz.interfaces.files import ISourcePackageReleaseFile
18 from lp.soyuz.interfaces.publishing import (
19 DeletionError,
20 IBinaryPackagePublishingHistory,
21@@ -152,6 +154,17 @@ class ArchivePublisherBase:
22 """See `IPublishing`"""
23 try:
24 for pub_file in self.files:
25+ # XXX ilasc 2022-14-11 We want to exclude the Conda source
26+ # packages as a temporary workaround to overcome the issue of
27+ # the publisher crashing when the package contains files
28+ # missing required metadata as was the case of the missing
29+ # `subdir` from info/index.json file.
30+ if (
31+ self.archive.repository_format
32+ == ArchiveRepositoryFormat.CONDA
33+ and ISourcePackageReleaseFile.providedBy(pub_file)
34+ ):
35+ continue
36 pool_name = self.pool_name
37 pool_version = self.pool_version
38 component = (
39diff --git a/lib/lp/soyuz/tests/test_publishing.py b/lib/lp/soyuz/tests/test_publishing.py
40index ff6e308..8a84a1a 100644
41--- a/lib/lp/soyuz/tests/test_publishing.py
42+++ b/lib/lp/soyuz/tests/test_publishing.py
43@@ -10,6 +10,7 @@ import os
44 import shutil
45 import tempfile
46 from functools import partial
47+from unittest import mock
48
49 import pytz
50 import transaction
51@@ -19,6 +20,7 @@ from zope.component import getUtility
52 from zope.security.proxy import removeSecurityProxy
53
54 from lp.app.errors import NotFoundError
55+from lp.archivepublisher.artifactory import ArtifactoryPool
56 from lp.archivepublisher.config import getPubConfig
57 from lp.archivepublisher.diskpool import DiskPool
58 from lp.archivepublisher.indices import (
59@@ -43,7 +45,7 @@ from lp.services.channels import channel_string_to_list
60 from lp.services.config import config
61 from lp.services.database.constants import UTC_NOW
62 from lp.services.librarian.interfaces import ILibraryFileAliasSet
63-from lp.services.log.logger import DevNullLogger
64+from lp.services.log.logger import BufferLogger, DevNullLogger
65 from lp.soyuz.enums import (
66 ArchivePublishingMethod,
67 ArchivePurpose,
68@@ -874,6 +876,24 @@ class TestNativePublishing(TestNativePublishingBase):
69 pool_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir
70 self.assertEqual(open(pool_path).read().strip(), "Hello world")
71
72+ @mock.patch.object(ArtifactoryPool, "addFile")
73+ def test_publisher_skips_conda_source_packages(self, mock):
74+ root_url = "https://foo.example.com/artifactory/repository"
75+ archive = self.factory.makeArchive(
76+ purpose=ArchivePurpose.PPA,
77+ repository_format=ArchiveRepositoryFormat.CONDA,
78+ )
79+ pool = ArtifactoryPool(archive, root_url, BufferLogger())
80+ # getPubSource returns a SourcePackagePublishingHistory object
81+ pub_source = self.getPubSource(
82+ filecontent=b"Hello world",
83+ archive=archive,
84+ format=SourcePackageType.CI_BUILD,
85+ user_defined_fields=[("bogus_filed", "instead_of_subdir")],
86+ )
87+ pub_source.publish(pool, self.logger)
88+ self.assertFalse(mock.called)
89+
90 def test_publish_binaries(self):
91 # Binary publications result in a PUBLISHED publishing record and
92 # the corresponding files are dumped in the disk pool/.

Subscribers

People subscribed via source and target branches

to status/vote changes: