[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-mojo-specs/+git/private:fetch-service-revision-bump-to-6 into ~launchpad/launchpad-mojo-specs/+git/private:master

2024-04-29 Thread Simone Pelosi
The proposal to merge 
~pelpsi/launchpad-mojo-specs/+git/private:fetch-service-revision-bump-to-6 into 
~launchpad/launchpad-mojo-specs/+git/private:master has been updated.

Status: Needs review => Approved

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-mojo-specs/+git/private/+merge/465158
-- 
Your team Launchpad code reviewers is subscribed to branch 
~launchpad/launchpad-mojo-specs/+git/private:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-mojo-specs/+git/private:fetch-service-revision-bump-to-6 into ~launchpad/launchpad-mojo-specs/+git/private:master

2024-04-29 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad-mojo-specs/+git/private:fetch-service-revision-bump-to-6 into 
~launchpad/launchpad-mojo-specs/+git/private:master.

Commit message:
lp-fetch-service: bump fetch-service revision to 6


Requested reviews:
  Canonical Launchpad Engineering (launchpad)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-mojo-specs/+git/private/+merge/465158
-- 
Your team Launchpad code reviewers is subscribed to branch 
~launchpad/launchpad-mojo-specs/+git/private:master.
diff --git a/lp-fetch-service/bundle.yaml b/lp-fetch-service/bundle.yaml
index 05c64b8..14bd8a7 100644
--- a/lp-fetch-service/bundle.yaml
+++ b/lp-fetch-service/bundle.yaml
@@ -18,7 +18,7 @@ applications:
 .../mojo/lp-fetch-service/jammy/devel/charms/lp-fetch-service/). #}
 charm: ch:fetch-service
 channel: edge
-revision: 4
+revision: 6
 num_units: 1
 expose: true
 options:
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-buildd:handle-base64-certificate into launchpad-buildd:master

2024-04-26 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad-buildd:handle-base64-certificate into launchpad-buildd:master.

Commit message:
Handle Base64 certificate

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/465049
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad-buildd:handle-base64-certificate into launchpad-buildd:master.
diff --git a/lpbuildd/target/build_snap.py b/lpbuildd/target/build_snap.py
index 5adbb76..94b1ea0 100644
--- a/lpbuildd/target/build_snap.py
+++ b/lpbuildd/target/build_snap.py
@@ -2,6 +2,7 @@
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 import argparse
+import base64
 import json
 import logging
 import os.path
@@ -122,9 +123,13 @@ class BuildSnap(
 requests when fetching dependencies.
 """
 with self.backend.open(
-"/usr/local/share/ca-certificates/local-ca.crt", mode="w"
+"/usr/local/share/ca-certificates/local-ca.crt",
+mode="wb"
 ) as local_ca_cert:
-local_ca_cert.write(self.args.fetch_service_mitm_certificate)
+decoded_certificate = base64.b64decode(
+self.args.fetch_service_mitm_certificate.encode("ASCII")
+)
+local_ca_cert.write(decoded_certificate)
 os.fchmod(local_ca_cert.fileno(), 0o644)
 self.backend.run(["update-ca-certificates"])
 # XXX jugmac00 2024-04-17: We might need to restart snapd
diff --git a/lpbuildd/target/tests/test_build_snap.py b/lpbuildd/target/tests/test_build_snap.py
index 4788029..33b1e0d 100644
--- a/lpbuildd/target/tests/test_build_snap.py
+++ b/lpbuildd/target/tests/test_build_snap.py
@@ -208,7 +208,8 @@ class TestBuildSnap(TestCase):
 "test-snap",
 "--use_fetch_service",
 "--fetch-service-mitm-certificate",
-"content_of_cert",
+# Base64 content_of_cert
+"Y29udGVudF9vZl9jZXJ0",
 ]
 build_snap = parse_args(args=args).operation
 build_snap.bin = "/builderbin"
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-buildd:fix-cerf-file-permissions into launchpad-buildd:master

2024-04-24 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad-buildd:fix-cerf-file-permissions into launchpad-buildd:master.

Commit message:
Give to the cert file the right permissions

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/464915
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad-buildd:fix-cerf-file-permissions into launchpad-buildd:master.
diff --git a/lpbuildd/target/build_snap.py b/lpbuildd/target/build_snap.py
index f29e3d5..5adbb76 100644
--- a/lpbuildd/target/build_snap.py
+++ b/lpbuildd/target/build_snap.py
@@ -125,6 +125,7 @@ class BuildSnap(
 "/usr/local/share/ca-certificates/local-ca.crt", mode="w"
 ) as local_ca_cert:
 local_ca_cert.write(self.args.fetch_service_mitm_certificate)
+os.fchmod(local_ca_cert.fileno(), 0o644)
 self.backend.run(["update-ca-certificates"])
 # XXX jugmac00 2024-04-17: We might need to restart snapd
 # so the new certificate will be used
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:add-fetch-service-certificate-to-secrets into launchpad:master

2024-04-23 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:add-fetch-service-certificate-to-secrets into 
launchpad:master.

Commit message:
Add fetch_service_mitm_certificate to secrets

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/464850
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:add-fetch-service-certificate-to-secrets into 
launchpad:master.
diff --git a/charm/launchpad-buildd-manager/templates/launchpad-buildd-manager-secrets-lazr.conf b/charm/launchpad-buildd-manager/templates/launchpad-buildd-manager-secrets-lazr.conf
index 7637fcb..9b306c1 100644
--- a/charm/launchpad-buildd-manager/templates/launchpad-buildd-manager-secrets-lazr.conf
+++ b/charm/launchpad-buildd-manager/templates/launchpad-buildd-manager-secrets-lazr.conf
@@ -16,3 +16,4 @@
 [builddmaster]
 {{- opt("builder_proxy_auth_api_admin_secret", builder_proxy_auth_api_admin_secret) }}
 {{- opt("fetch_service_control_admin_secret", fetch_service_control_admin_secret) }}
+{{- opt("fetch_service_mitm_certificate", fetch_service_mitm_certificate) }}
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-mojo-specs/+git/private:fetch-service-charmhub-configuration into ~launchpad/launchpad-mojo-specs/+git/private:master

2024-04-23 Thread Simone Pelosi
The proposal to merge 
~pelpsi/launchpad-mojo-specs/+git/private:fetch-service-charmhub-configuration 
into ~launchpad/launchpad-mojo-specs/+git/private:master has been updated.

Status: Needs review => Approved

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-mojo-specs/+git/private/+merge/464821
-- 
Your team Launchpad code reviewers is subscribed to branch 
~launchpad/launchpad-mojo-specs/+git/private:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-mojo-specs/+git/private:fetch-service-charmhub-configuration into ~launchpad/launchpad-mojo-specs/+git/private:master

2024-04-23 Thread Simone Pelosi
The proposal to merge 
~pelpsi/launchpad-mojo-specs/+git/private:fetch-service-charmhub-configuration 
into ~launchpad/launchpad-mojo-specs/+git/private:master has been updated.

Commit message changed to:

lp-fetch-service: Deploy fetch-service charm from Charmhub

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-mojo-specs/+git/private/+merge/464821
-- 
Your team Launchpad code reviewers is subscribed to branch 
~launchpad/launchpad-mojo-specs/+git/private:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:unembargo-buildinfo-file into launchpad:master

2024-04-23 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/launchpad:unembargo-buildinfo-file 
into launchpad:master.

Commit message:
Unembargo build info

Added buildinfo to unembargoed files.

LP: #2052796

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #2052796 in Launchpad itself: "MIssing buildinfo file for Jammy 
grub2-unsigned 2.06-2ubuntu14.4"
  https://bugs.launchpad.net/launchpad/+bug/2052796

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/464838
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:unembargo-buildinfo-file into launchpad:master.
diff --git a/lib/lp/soyuz/scripts/packagecopier.py b/lib/lp/soyuz/scripts/packagecopier.py
index f377107..bc31af0 100644
--- a/lib/lp/soyuz/scripts/packagecopier.py
+++ b/lib/lp/soyuz/scripts/packagecopier.py
@@ -87,6 +87,8 @@ def update_files_privacy(pub_record):
 package_files.append((package_upload, "changesfile"))
 # Unrestrict the buildlog file as necessary.
 package_files.append((build, "log"))
+# Unrestrict the buildinfo file as necessary.
+package_files.append((build, "buildinfo"))
 elif IPackageUploadCustom.providedBy(pub_record):
 # Unrestrict the custom files included
 package_files.append((pub_record, "libraryfilealias"))
diff --git a/lib/lp/soyuz/tests/test_packagecopyjob.py b/lib/lp/soyuz/tests/test_packagecopyjob.py
index 26fdd08..033dd6a 100644
--- a/lib/lp/soyuz/tests/test_packagecopyjob.py
+++ b/lib/lp/soyuz/tests/test_packagecopyjob.py
@@ -1757,6 +1757,12 @@ class PlainPackageCopyJobTests(TestCaseWithFactory, LocalTestHelper):
 distroseries=self.distroseries,
 status=PackagePublishingStatus.PUBLISHED,
 )
+[build] = spph.getBuilds()
+build.addBuildInfo(
+self.factory.makeLibraryFileAlias(
+filename="build_info.info", restricted=True
+)
+)
 spr = spph.sourcepackagerelease
 for source_file in spr.files:
 self.assertTrue(source_file.libraryfile.restricted)
@@ -1837,6 +1843,7 @@ class PlainPackageCopyJobTests(TestCaseWithFactory, LocalTestHelper):
 copied_build = copied_binary.binarypackagerelease.build
 self.assertFalse(copied_build.upload_changesfile.restricted)
 self.assertFalse(copied_build.log.restricted)
+self.assertFalse(copied_build.buildinfo.restricted)
 
 def test_copy_custom_upload_files(self):
 # Copyable custom upload files are queued for republication when
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-mojo-specs/+git/private:fetch-service-charmhub-configuration into ~launchpad/launchpad-mojo-specs/+git/private:master

2024-04-23 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad-mojo-specs/+git/private:fetch-service-charmhub-configuration 
into ~launchpad/launchpad-mojo-specs/+git/private:master.

Commit message:
Get fetch-service from Charmhub

Requested reviews:
  Canonical Launchpad Engineering (launchpad)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-mojo-specs/+git/private/+merge/464821
-- 
Your team Launchpad code reviewers is subscribed to branch 
~launchpad/launchpad-mojo-specs/+git/private:master.
diff --git a/lp-fetch-service/bundle.yaml b/lp-fetch-service/bundle.yaml
index 8bd8dd3..67472ee 100644
--- a/lp-fetch-service/bundle.yaml
+++ b/lp-fetch-service/bundle.yaml
@@ -16,9 +16,11 @@ applications:
 public. Currently, this expects the charm and snap to be copied to the
 path where the bundle.yaml is rendered, in the mojo project folder (eg.
 .../mojo/lp-fetch-service/jammy/devel/charms/lp-fetch-service/). #}
-charm: "./fetch-service_ubuntu-22.04-amd64.charm"
-resources:
-  snap: "./fetch-service.snap"
+charm: ch:fetch-service
+channel: edge
+revision: 4
 num_units: 1
 expose: true
+options:
+channel: "latest/edge"
 {%- endif %}
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:unembargo-bug-build-info-missing into launchpad:master

2024-04-19 Thread Simone Pelosi
The proposal to merge ~pelpsi/launchpad:unembargo-bug-build-info-missing into 
launchpad:master has been updated.

Status: Needs review => Work in progress

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/464705
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:unembargo-bug-build-info-missing into launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:unembargo-bug-build-info-missing into launchpad:master

2024-04-19 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:unembargo-bug-build-info-missing into launchpad:master.

Commit message:
Unembargo build info

Added buildinfo to unembargoed files.
Added custom upload files to unembargoed files.
Added a new endpoint buildMetadataFileUrls to retrieve
changes file, build_info and log without accessing directly the build.

LP: #2052796


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #2052796 in Launchpad itself: "MIssing buildinfo file for Jammy 
grub2-unsigned 2.06-2ubuntu14.4"
  https://bugs.launchpad.net/launchpad/+bug/2052796

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/464705
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:unembargo-bug-build-info-missing into launchpad:master.
diff --git a/lib/lp/soyuz/browser/tests/test_publishing_webservice.py b/lib/lp/soyuz/browser/tests/test_publishing_webservice.py
index 2aee350..b167e61 100644
--- a/lib/lp/soyuz/browser/tests/test_publishing_webservice.py
+++ b/lib/lp/soyuz/browser/tests/test_publishing_webservice.py
@@ -15,9 +15,14 @@ from lp.services.librarian.browser import ProxiedLibraryFileAlias
 from lp.services.webapp.interfaces import OAuthPermission
 from lp.soyuz.adapters.proxiedsourcefiles import ProxiedSourceLibraryFileAlias
 from lp.soyuz.enums import BinaryPackageFormat
-from lp.soyuz.interfaces.publishing import IPublishingSet
+from lp.soyuz.interfaces.publishing import (
+IPublishingSet,
+PackagePublishingStatus,
+)
+from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
 from lp.testing import (
 TestCaseWithFactory,
+admin_logged_in,
 api_url,
 login_person,
 person_logged_in,
@@ -167,14 +172,47 @@ class SourcePackagePublishingHistoryWebserviceTests(TestCaseWithFactory):
 class BinaryPackagePublishingHistoryWebserviceTests(TestCaseWithFactory):
 layer = LaunchpadFunctionalLayer
 
+def setUp(self):
+super().setUp()
+self.processor = self.factory.makeProcessor(supports_virtualized=True)
+self.distroseries = self.factory.makeDistroSeries()
+self.das = self.factory.makeDistroArchSeries(
+distroseries=self.distroseries, processor=self.processor
+)
+with admin_logged_in():
+self.publisher = SoyuzTestPublisher()
+self.publisher.prepareBreezyAutotest()
+self.distroseries.nominatedarchindep = self.das
+self.publisher.addFakeChroots(distroseries=self.distroseries)
+self.builder = self.factory.makeBuilder(
+processors=[self.processor]
+)
+
 def make_bpph_for(self, person):
+spn = self.factory.getUniqueString()
+version = "%s.1" % self.factory.getUniqueInteger()
 with person_logged_in(person):
-bpr = self.factory.makeBinaryPackageRelease()
-self.factory.makeBinaryPackageFile(binarypackagerelease=bpr)
-bpph = self.factory.makeBinaryPackagePublishingHistory(
-binarypackagerelease=bpr
+spph = self.publisher.getPubSource(
+sourcename=spn,
+version=version,
+distroseries=self.distroseries,
+status=PackagePublishingStatus.PUBLISHED,
+)
+with admin_logged_in():
+binary = self.publisher.getPubBinaries(
+binaryname=spn,
+distroseries=self.distroseries,
+pub_source=spph,
+version=version,
+builder=self.builder,
+)
+binary[0].build.addBuildInfo(
+self.factory.makeLibraryFileAlias(
+filename="build_info.info", restricted=True
+)
 )
-return bpph, api_url(bpph)
+
+return binary[0], api_url(binary[0])
 
 def test_binaryFileUrls(self):
 person = self.factory.makePerson()
@@ -239,6 +277,71 @@ class BinaryPackagePublishingHistoryWebserviceTests(TestCaseWithFactory):
 ]
 self.assertContentEqual(expected_info, info)
 
+def test_buildMetadataFileUrls(self):
+person = self.factory.makePerson()
+webservice = webservice_for_person(
+person, permission=OAuthPermission.READ_PUBLIC
+)
+bpph, url = self.make_bpph_for(person)
+
+response = webservice.named_get(
+url, "buildMetadataFileUrls", api_version="devel"
+)
+
+self.assertEqual(200, response.status)
+urls = response.jsonBody()
+
+with person_logged_in(person):
+upload_changesfile = (
+bpph.binarypackagerelease.build.upload_changesfile
+)
+log = bpph.binarypackagerelease.build.log
+build_info = bpph.binarypackagere

Re: [Launchpad-reviewers] [Merge] ~jugmac00/launchpad:expose-build-metadata-via-api into launchpad:master

2024-04-19 Thread Simone Pelosi
I just add there what we found during the peer programming session :)

Diff comments:

> diff --git a/lib/lp/snappy/interfaces/snapbuild.py 
> b/lib/lp/snappy/interfaces/snapbuild.py
> index 52019bf..46bd205 100644
> --- a/lib/lp/snappy/interfaces/snapbuild.py
> +++ b/lib/lp/snappy/interfaces/snapbuild.py
> @@ -370,6 +371,14 @@ class ISnapBuildView(IPackageBuildView, IPrivacy):
>  
>  :return: A collection of URLs for this build."""
>  
> +@export_operation_as("build_metadata_url")
> +@export_read_operation()
> +@operation_for_version("devel")
> +def getBuildMetadataUrl():
> +"""URLs for all the files produced by this build.
> +
> +:return: A collection of URLs for this build."""

Since we are returning None if the metadata is not present we should specify 
that in the docstring, I would say something like: Metadata file URL, None if 
the metadada file is not present.

> +
>  
>  class ISnapBuildEdit(IBuildFarmJobEdit):
>  """`ISnapBuild` attributes that require launchpad.Edit."""
> diff --git a/lib/lp/snappy/model/snapbuild.py 
> b/lib/lp/snappy/model/snapbuild.py
> index df2e2c2..13a52b8 100644
> --- a/lib/lp/snappy/model/snapbuild.py
> +++ b/lib/lp/snappy/model/snapbuild.py
> @@ -425,6 +425,11 @@ class SnapBuild(PackageBuildMixin, StormBase):
>  def getFileUrls(self):
>  return [self.lfaUrl(lfa) for _, lfa, _ in self.getFiles()]
>  
> +def getBuildMetadataUrl(self):
> +for url in self.getFileUrls:

self.getFileUrls(), missing parentheses

> +if url.endswith("metadata.json"):
> +return url
> +
>  @cachedproperty
>  def eta(self):
>  """The datetime when the build job is estimated to complete.
> diff --git a/lib/lp/snappy/tests/test_snapbuild.py 
> b/lib/lp/snappy/tests/test_snapbuild.py
> index d8b7758..edc917e 100644
> --- a/lib/lp/snappy/tests/test_snapbuild.py
> +++ b/lib/lp/snappy/tests/test_snapbuild.py
> @@ -1009,6 +1009,21 @@ class TestSnapBuildWebservice(TestCaseWithFactory):
>  for file_url in file_urls:
>  self.assertCanOpenRedirectedUrl(browser, file_url)
>  
> +def test_getBuildMetadataUrl(self):
> +# API clients can fetch the metadata from the build, generated by the
> +# fetch service
> +db_build = self.factory.makeSnapBuild(requester=self.person)
> +metadata_file = self.factory.makeFileAlias(

s/self.factory.makeFileAlias/self.factory.makeLibraryFileAlias and wrap the 
file creation with:

```
with person_logged_in(self.person):
...
```

> +content="some_json",
> +filename="xxx-metadata.json",
> +)
> +db_build.addFile(metadata_file)
> +
> +build_url = api_url(db_build)
> +logout()
> +response = self.webservice.named_get(build_url, "build_metadata_url")
> +self.assertEndsWith(response.jsonBody(), "metadata.json")
> +
>  
>  class TestSnapBuildMacaroonIssuer(MacaroonTestMixin, TestCaseWithFactory):
>  """Test SnapBuild macaroon issuing and verification."""


-- 
https://code.launchpad.net/~jugmac00/launchpad/+git/launchpad/+merge/464639
Your team Launchpad code reviewers is requested to review the proposed merge of 
~jugmac00/launchpad:expose-build-metadata-via-api into launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:pass-information-via-XML-RPC-API-to-the-builders into launchpad:master

2024-04-15 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:pass-information-via-XML-RPC-API-to-the-builders into 
launchpad:master.

Commit message:
Passing certificate to the builders

Builders need certificate to configure correctly env to use
fetch service.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/464337
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:pass-information-via-XML-RPC-API-to-the-builders into 
launchpad:master.
diff --git a/charm/launchpad-buildd-manager/config.yaml b/charm/launchpad-buildd-manager/config.yaml
index caac316..630ce00 100644
--- a/charm/launchpad-buildd-manager/config.yaml
+++ b/charm/launchpad-buildd-manager/config.yaml
@@ -71,6 +71,10 @@ options:
   Fetch service host, it could be either a single instance 
   or a load balancer in front.
 default: ""
+  fetch_service_mitm_certificate:
+type: string
+description: Fetch service certificate.
+default: ""
   fetch_service_port:
 type: int
 description: Fetch service port.
diff --git a/lib/lp/buildmaster/builderproxy.py b/lib/lp/buildmaster/builderproxy.py
index 3375042..5f3cf5b 100644
--- a/lib/lp/buildmaster/builderproxy.py
+++ b/lib/lp/buildmaster/builderproxy.py
@@ -82,6 +82,13 @@ class BuilderProxyMixin:
 session_id=session["id"],
 )
 
+# Append the fetch-service certificate to BuildArgs secrets.
+if "secrets" not in args:
+args["secrets"] = {}
+args["secrets"]["fetch_service_mitm_certificate"] = (
+_get_value_from_config("fetch_service_mitm_certificate")
+)
+
 @defer.inlineCallbacks
 def _requestProxyToken(self):
 admin_username = _get_value_from_config(
diff --git a/lib/lp/buildmaster/tests/fetchservice.py b/lib/lp/buildmaster/tests/fetchservice.py
index 3fd879c..51f73e3 100644
--- a/lib/lp/buildmaster/tests/fetchservice.py
+++ b/lib/lp/buildmaster/tests/fetchservice.py
@@ -75,19 +75,18 @@ class InProcessFetchServiceAuthAPIFixture(fixtures.Fixture):
 self.addCleanup(site.stopFactory)
 port = yield endpoint.listen(site)
 self.addCleanup(port.stopListening)
-config.push(
-"in-process-fetch-service-api-fixture",
-dedent(
-"""
-[builddmaster]
-fetch_service_control_admin_secret: admin-secret
-fetch_service_control_admin_username: admin-launchpad.test
-fetch_service_control_endpoint: http://{host}:{port}/session
-fetch_service_host: {host}
-fetch_service_port: {port}
-"""
-).format(host=port.getHost().host, port=port.getHost().port),
-)
+configs = dedent(
+"""
+[builddmaster]
+fetch_service_control_admin_secret: admin-secret
+fetch_service_control_admin_username: admin-launchpad.test
+fetch_service_control_endpoint: http://{host}:{port}/session
+fetch_service_host: {host}
+fetch_service_port: {port}
+fetch_service_mitm_certificate: fake-cert
+"""
+).format(host=port.getHost().host, port=port.getHost().port)
+config.push("in-process-fetch-service-api-fixture", configs)
 self.addCleanup(config.pop, "in-process-fetch-service-api-fixture")
 
 
diff --git a/lib/lp/services/config/schema-lazr.conf b/lib/lp/services/config/schema-lazr.conf
index 94ca842..07f04c6 100644
--- a/lib/lp/services/config/schema-lazr.conf
+++ b/lib/lp/services/config/schema-lazr.conf
@@ -178,6 +178,9 @@ fetch_service_control_admin_username: none
 # Endpoint for fetch service authentication service
 fetch_service_control_endpoint: none
 
+# Fetch service certificate
+fetch_service_mitm_certificate: none
+
 # Fetch service host, it could be either a single instance 
 # or a load balancer in front
 fetch_service_host: none
@@ -1883,6 +1886,9 @@ fetch_service_control_admin_username: none
 # Endpoint for fetch service control service.
 fetch_service_control_endpoint: none
 
+# Fetch service certificate
+fetch_service_mitm_certificate: none
+
 # Fetch service host, it could be either a single instance 
 # or a load balancer in front.
 fetch_service_host: none
diff --git a/lib/lp/snappy/tests/test_snapbuildbehaviour.py b/lib/lp/snappy/tests/test_snapbuildbehaviour.py
index 2ccc18d..d20bf33 100644
--- a/lib/lp/snappy/tests/test_snapbuildbehaviour.py
+++ b/lib/lp/snappy/tests/test_snapbuildbehaviour.py
@@ -303,6 +303,28 @@ class TestAsyncSnapBuildBehaviourFetchService(
 self.assertNotIn("revocation_endpoint", args)
 
 @

[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-buildd:pass-information-via-XML-RPC-API-to-the-builders into launchpad-buildd:master

2024-04-15 Thread Simone Pelosi
The proposal to merge 
~pelpsi/launchpad-buildd:pass-information-via-XML-RPC-API-to-the-builders into 
launchpad-buildd:master has been updated.

Status: Needs review => Work in progress

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/464293
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad-buildd:pass-information-via-XML-RPC-API-to-the-builders into 
launchpad-buildd:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-buildd:pass-information-via-XML-RPC-API-to-the-builders into launchpad-buildd:master

2024-04-15 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad-buildd:pass-information-via-XML-RPC-API-to-the-builders into 
launchpad-buildd:master with 
~ines-almeida/launchpad-buildd:update-close-session-for-fetch-service as a 
prerequisite.

Commit message:
Pass information via XML-RPC API to the builders

Pass fetch-service proxy url containing token and session information.
Set env variables to use proxy globally and pass certificate.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/464293
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad-buildd:pass-information-via-XML-RPC-API-to-the-builders into 
launchpad-buildd:master.
diff --git a/lpbuildd/proxy.py b/lpbuildd/proxy.py
index 1a05ff3..4645091 100644
--- a/lpbuildd/proxy.py
+++ b/lpbuildd/proxy.py
@@ -224,18 +224,25 @@ class BuildManagerProxyMixin:
 """Start the local builder proxy, if necessary.
 
 This starts an internal proxy that stands before the Builder
-Proxy/Fetch Service, so build systems, which do not comply
-with standard `http(s)_proxy` environment variables, would
-still work with the builder proxy.
+Proxy/Fetch Service. It is important for certain build types.
 """
 if not self.proxy_url:
 return []
-proxy_port = self._builder._config.get("builder", "proxyport")
 proxy_factory = BuilderProxyFactory(self, self.proxy_url, timeout=60)
+proxy_port = self._builder._config.get("builder", "proxyport")
+
+if self._use_fetch_service:
+proxy_url = self.proxy_url.split("@")
+proxy_port = proxy_url.split(":")[-1]
+
 self.proxy_service = strports.service(
 "tcp:%s" % proxy_port, proxy_factory
 )
 self.proxy_service.setServiceParent(self._builder.service)
+
+if self._use_fetch_service:
+return ["--proxy-url", f"{self.proxy_url}"]
+
 if hasattr(self.backend, "ipv4_network"):
 proxy_host = self.backend.ipv4_network.ip
 else:
diff --git a/lpbuildd/target/build_snap.py b/lpbuildd/target/build_snap.py
index 82470d5..d649fad 100644
--- a/lpbuildd/target/build_snap.py
+++ b/lpbuildd/target/build_snap.py
@@ -106,7 +106,7 @@ class BuildSnap(
 "--use_fetch_service",
 default=False,
 action="store_true",
-help="use the fetch service instead of the builder proxy",
+help="use the fetch service instead of the old builder proxy",
 )
 parser.add_argument("name", help="name of snap to build")
 
diff --git a/lpbuildd/target/tests/test_build_snap.py b/lpbuildd/target/tests/test_build_snap.py
index 8719e57..30f0c8f 100644
--- a/lpbuildd/target/tests/test_build_snap.py
+++ b/lpbuildd/target/tests/test_build_snap.py
@@ -194,6 +194,55 @@ class TestBuildSnap(TestCase):
 build_snap.backend.backend_fs["/root/.subversion/servers"],
 )
 
+def test_install_fetch_service(self):
+args = [
+"buildsnap",
+"--backend=fake",
+"--series=xenial",
+"--arch=amd64",
+"1",
+"--git-repository",
+"lp:foo",
+"--proxy-url",
+"http://session:token@fetch-service.proxy:9988;,
+"test-snap",
+"--use_fetch_service"
+]
+build_snap = parse_args(args=args).operation
+build_snap.bin = "/builderbin"
+self.useFixture(FakeFilesystem()).add("/builderbin")
+os.mkdir("/builderbin")
+with open("/builderbin/lpbuildd-git-proxy", "w") as proxy_script:
+proxy_script.write("proxy script\n")
+os.fchmod(proxy_script.fileno(), 0o755)
+build_snap.install()
+self.assertThat(
+build_snap.backend.run.calls,
+MatchesListwise(
+[
+RanAptGet(
+"install", "python3", "socat", "git", "snapcraft"
+),
+RanCommand(["mkdir", "-p", "/root/.subversion"]),
+]
+),
+)
+self.assertEqual(
+(b"proxy script\n", stat.S_IFREG | 0o755),
+build_snap.backend.backend_fs["/usr/local/bin/lpbuildd-git-proxy"],
+)
+self.assertEqual(
+(
+b"[global]\n&qu

[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-buildd:pass-information-via-XML-RPC-API-to-the-builders into launchpad-buildd:master

2024-04-15 Thread Simone Pelosi
The proposal to merge 
~pelpsi/launchpad-buildd:pass-information-via-XML-RPC-API-to-the-builders into 
launchpad-buildd:master has been updated.

Status: Work in progress => Superseded

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/464292
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad-buildd:pass-information-via-XML-RPC-API-to-the-builders into 
launchpad-buildd:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~ines-almeida/launchpad-mojo-specs/+git/private:fetch-service-fix-typo into ~launchpad/launchpad-mojo-specs/+git/private:master

2024-04-08 Thread Simone Pelosi
Review: Approve


-- 
https://code.launchpad.net/~ines-almeida/launchpad-mojo-specs/+git/private/+merge/463831
Your team Launchpad code reviewers is subscribed to branch 
~launchpad/launchpad-mojo-specs/+git/private:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~pelpsi/launchpad:snap-component-integration into launchpad:master

2024-03-27 Thread Simone Pelosi
Thank you for your precious reviews, I firstly addressed some of your comments 
here, and I'm working to remove snapcraft.yaml logic to search for components 
as suggested by William. I will use the build files to retrieve them. 

I also had a chat with Przemysław, and he clarified that snap_name cannot 
contain `+` nor `_`, the same as component_name. So it should be easier to 
extract the component name in that context 
`+_.comp`.

Diff comments:

> diff --git a/lib/lp/snappy/model/snapbuildjob.py 
> b/lib/lp/snappy/model/snapbuildjob.py
> index 539fb1c..80260c1 100644
> --- a/lib/lp/snappy/model/snapbuildjob.py
> +++ b/lib/lp/snappy/model/snapbuildjob.py
> @@ -333,6 +351,24 @@ class SnapStoreUploadJob(SnapBuildJobDerived):
>  pass
>  return timedelta(minutes=1)
>  
> +@staticmethod
> +def _extract_component_name(filename, snapcraft_components):
> +"""Extract component name from filename
> +
> +Use the snapcraft_components keys to extract the component name
> +from the built component filename. Each key correspond to
> + while the built filename has the following pattern:
> ++_.comp.
> +"""
> +for component in snapcraft_components:
> +# Surround component name with `+` and `_` to avoid
> +# superset of the same component name.
> +# ie. testcomp -> testcomponent
> +built_component = "+%s_" % component

This chance doesn't exist since we are surrounding the comp name with `+` and 
`_` before checking. But I have to change this function and revert it to the 
previous behavior because as said by William snapcraft.yaml is not reliable.

> +if built_component in filename:
> +return component
> +return filename
> +
>  def run(self):
>  """See `IRunnableJob`."""
>  client = getUtility(ISnapStoreClient)
> @@ -350,16 +386,54 @@ class SnapStoreUploadJob(SnapBuildJobDerived):
>  # Nothing to do.
>  self.error_message = None
>  return
> +
> +components_ids = {}
> +components = []
> +try:
> +# Get components from snapcraft.yaml
> +snapcraft_yaml = getUtility(ISnapSet).getSnapcraftYaml(
> +self.snapbuild.snap
> +)
> +if snapcraft_yaml["components"]:
> +for component in snapcraft_yaml["components"]:
> +components_ids[component] = None
> +# Get built components from built files
> +for _, lfa, _ in self.snapbuild.getFiles():
> +if lfa.filename.endswith(".comp"):
> +components.append(lfa)
> +except (
> +MissingSnapcraftYaml,
> +CannotFetchSnapcraftYaml,
> +CannotParseSnapcraftYaml,
> +):
> +pass
> +
> +if "components_ids" not in self.store_metadata:
> +self.components_ids = components_ids
>  if "upload_id" not in self.store_metadata:
>  self.upload_id = client.uploadFile(snap_lfa)
>  # We made progress, so reset attempt_count.
>  self.attempt_count = 1
> +# Process components
> +for component in components:
> +# if the id is None, we need to upload the component
> +# because it means that that component was never 
> uploaded.
> +# Note that the id is returned directly from SnapStore 
> API.
> +comp_name = self._extract_component_name(
> +component.filename, components_ids
> +)
> +if self.components_ids.get(comp_name) == None:
> +self.components_ids[comp_name] = client.uploadFile(
> +component
> +)

Yep, `test_run_502_retries_with_components` tests the mentioned behavior: note 
that we are committing when we are handling an Exception:
```
except Exception:
# The normal job infrastructure will abort the transaction, but
# we want to commit instead: the only database changes we make
# are to this job's metadata and should be preserved.
transaction.commit()
raise
```

> +self.attempt_count = 1
>  if "status_url" not in self.store_metadata:
>  self.status_url = client.push(
> -self.snapbuild, self.upload_id
> +self.snapbuild, self.upload_id, self.components_ids
>  )
>  # We made progress, so reset 

[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:snap-component-integration into launchpad:master

2024-03-14 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/launchpad:snap-component-integration 
into launchpad:master.

Commit message:
Add Snap Component support

Reference: LP142
Snap Components are processed and uploaded to the
snapcraft storage before pushing the Snap to the store.
Once every component is updated on the storage we can push
the Snap to the store.
push` function changed to support the new `components` parameter.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/461063
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:snap-component-integration into launchpad:master.
diff --git a/lib/lp/snappy/interfaces/snapbuildjob.py b/lib/lp/snappy/interfaces/snapbuildjob.py
index 12e4b8b..c1bfc24 100644
--- a/lib/lp/snappy/interfaces/snapbuildjob.py
+++ b/lib/lp/snappy/interfaces/snapbuildjob.py
@@ -13,7 +13,7 @@ __all__ = [
 from lazr.restful.fields import Reference
 from zope.interface import Attribute, Interface
 from zope.interface.interfaces import IObjectEvent
-from zope.schema import Int, TextLine
+from zope.schema import Dict, Int, TextLine
 
 from lp import _
 from lp.services.job.interfaces.job import IJob, IJobSource, IRunnableJob
@@ -68,6 +68,15 @@ class ISnapStoreUploadJob(IRunnableJob):
 readonly=True,
 )
 
+components_ids = Dict(
+title=_(
+"The IDs returned by the store when uploading snap components."
+"The key is the component name and the value is the related id."
+),
+required=False,
+readonly=True,
+)
+
 status_url = TextLine(
 title=_("The URL on the store to get the status of this build"),
 required=False,
diff --git a/lib/lp/snappy/model/snapbuildjob.py b/lib/lp/snappy/model/snapbuildjob.py
index 539fb1c..0384b0c 100644
--- a/lib/lp/snappy/model/snapbuildjob.py
+++ b/lib/lp/snappy/model/snapbuildjob.py
@@ -244,6 +244,18 @@ class SnapStoreUploadJob(SnapBuildJobDerived):
 self.snapbuild.store_upload_metadata["upload_id"] = upload_id
 
 @property
+def components_ids(self):
+"""See `ISnapStoreUploadJob`."""
+return self.store_metadata.get("components_ids")
+
+@components_ids.setter
+def components_ids(self, components_ids):
+"""See `ISnapStoreUploadJob`."""
+if self.snapbuild.store_upload_metadata is None:
+self.snapbuild.store_upload_metadata = {}
+self.snapbuild.store_upload_metadata["components_ids"] = components_ids
+
+@property
 def status_url(self):
 """See `ISnapStoreUploadJob`."""
 return self.store_metadata.get("status_url")
@@ -333,6 +345,15 @@ class SnapStoreUploadJob(SnapBuildJobDerived):
 pass
 return timedelta(minutes=1)
 
+def _extract_component_name(self, filename):
+# +_.comp
+start = filename.find("+")
+end = filename.rfind("_")
+if start == -1 or end == -1:
+return filename
+else:
+return filename[start + 1 : end]
+
 def run(self):
 """See `IRunnableJob`."""
 client = getUtility(ISnapStoreClient)
@@ -346,6 +367,17 @@ class SnapStoreUploadJob(SnapBuildJobDerived):
 ),
 None,
 )
+# Get components if any
+components = []
+components_ids = {}
+for _, lfa, _ in self.snapbuild.getFiles():
+if lfa.filename.endswith(".comp"):
+comp_name = self._extract_component_name(lfa.filename)
+components_ids[comp_name] = None
+components.append(lfa)
+
+if "components_ids" not in self.store_metadata:
+self.components_ids = components_ids
 if snap_lfa is None:
 # Nothing to do.
 self.error_message = None
@@ -354,12 +386,24 @@ class SnapStoreUploadJob(SnapBuildJobDerived):
 self.upload_id = client.uploadFile(snap_lfa)
 # We made progress, so reset attempt_count.
 self.attempt_count = 1
+# Process components
+for component in components:
+# if the id is None, we need to upload the component
+comp_name = self._extract_component_name(
+component.filename
+)
+if self.components_ids.get(comp_name) == None:
+self.components_ids[comp_name] = client.uploadFile(
+compone

[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:launchpad-build-manager-fetch-service-support into launchpad:master

2024-03-13 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:launchpad-build-manager-fetch-service-support into 
launchpad:master.

Commit message:
Update launchpad-buildd-manager to support Fetch Service

Add configs for fetch service into launchpad-buildd-manager charm.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/462334
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:launchpad-build-manager-fetch-service-support into 
launchpad:master.
diff --git a/charm/launchpad-buildd-manager/config.yaml b/charm/launchpad-buildd-manager/config.yaml
index 58cbfe4..caac316 100644
--- a/charm/launchpad-buildd-manager/config.yaml
+++ b/charm/launchpad-buildd-manager/config.yaml
@@ -52,6 +52,28 @@ options:
   YAML-encoded dictionary mapping pillars to dictionaries of
   configuration items to set for CI builds of those pillars.
 default: ""
+  fetch_service_control_admin_secret:
+type: string
+description: >
+  Admin secret for requesting sessions from the fetch service.
+default: ""
+  fetch_service_control_admin_username:
+type: string
+description: Admin username for fetch service.
+default: ""
+  fetch_service_control_endpoint:
+type: string
+description: Endpoint for fetch service control service.
+default: ""
+  fetch_service_host:
+type: string
+description: >
+  Fetch service host, it could be either a single instance 
+  or a load balancer in front.
+default: ""
+  fetch_service_port:
+type: int
+description: Fetch service port.
   socket_timeout:
 type: int
 description: >
diff --git a/charm/launchpad-buildd-manager/templates/launchpad-buildd-manager-lazr.conf b/charm/launchpad-buildd-manager/templates/launchpad-buildd-manager-lazr.conf
index 3641a19..aed4cdf 100644
--- a/charm/launchpad-buildd-manager/templates/launchpad-buildd-manager-lazr.conf
+++ b/charm/launchpad-buildd-manager/templates/launchpad-buildd-manager-lazr.conf
@@ -18,6 +18,10 @@ authentication_timeout: {{ authentication_timeout }}
 {{- opt("builder_proxy_auth_api_endpoint", builder_proxy_auth_api_endpoint) }}
 {{- opt("builder_proxy_host", builder_proxy_host) }}
 {{- opt("builder_proxy_port", builder_proxy_port) }}
+{{- opt("fetch_service_control_admin_username", fetch_service_control_admin_username) }}
+{{- opt("fetch_service_control_endpoint", fetch_service_control_endpoint) }}
+{{- opt("fetch_service_host", fetch_service_host) }}
+{{- opt("fetch_service_port", fetch_service_port) }}
 root: {{ buildd_manager_dir }}
 socket_timeout: {{ socket_timeout }}
 virtualized_socket_timeout: {{ virtualized_socket_timeout }}
diff --git a/charm/launchpad-buildd-manager/templates/launchpad-buildd-manager-secrets-lazr.conf b/charm/launchpad-buildd-manager/templates/launchpad-buildd-manager-secrets-lazr.conf
index af20066..7637fcb 100644
--- a/charm/launchpad-buildd-manager/templates/launchpad-buildd-manager-secrets-lazr.conf
+++ b/charm/launchpad-buildd-manager/templates/launchpad-buildd-manager-secrets-lazr.conf
@@ -15,4 +15,4 @@
 
 [builddmaster]
 {{- opt("builder_proxy_auth_api_admin_secret", builder_proxy_auth_api_admin_secret) }}
-
+{{- opt("fetch_service_control_admin_secret", fetch_service_control_admin_secret) }}
diff --git a/lib/lp/services/config/schema-lazr.conf b/lib/lp/services/config/schema-lazr.conf
index bbfe8b8..fed991a 100644
--- a/lib/lp/services/config/schema-lazr.conf
+++ b/lib/lp/services/config/schema-lazr.conf
@@ -1880,14 +1880,14 @@ fetch_service_control_admin_secret: none
 # Admin username for fetch service.
 fetch_service_control_admin_username: none
 
-# Endpoint for fetch service authentication service
+# Endpoint for fetch service control service.
 fetch_service_control_endpoint: none
 
 # Fetch service host, it could be either a single instance 
-# or a load balancer in front
+# or a load balancer in front.
 fetch_service_host: none
 
-# Fetch service port
+# Fetch service port.
 fetch_service_port: none
 
 # Optional sources.list entry to send to build workers when doing snap
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:fetch-service-revocation-endpoint-fix into launchpad:master

2024-03-12 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:fetch-service-revocation-endpoint-fix into launchpad:master.

Commit message:
Fix revocation endpoint

fetch_service_control_endpoint already has the following structure:
http://host:port/session


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/462260
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:fetch-service-revocation-endpoint-fix into launchpad:master.
diff --git a/lib/lp/buildmaster/builderproxy.py b/lib/lp/buildmaster/builderproxy.py
index 75e049f..a747b61 100644
--- a/lib/lp/buildmaster/builderproxy.py
+++ b/lib/lp/buildmaster/builderproxy.py
@@ -77,7 +77,7 @@ class BuilderProxyMixin:
 port=_get_proxy_config("fetch_service_port"),
 )
 )
-args["revocation_endpoint"] = "{endpoint}/session/{id}".format(
+args["revocation_endpoint"] = "{endpoint}/{id}".format(
 endpoint=_get_proxy_config("fetch_service_control_endpoint"),
 id=session["id"],
 )
diff --git a/lib/lp/buildmaster/tests/fetchservice.py b/lib/lp/buildmaster/tests/fetchservice.py
index ea70651..dd21e27 100644
--- a/lib/lp/buildmaster/tests/fetchservice.py
+++ b/lib/lp/buildmaster/tests/fetchservice.py
@@ -117,7 +117,7 @@ class RevocationEndpointMatcher(Equals):
 
 def __init__(self, session_id):
 super().__init__(
-"{endpoint}/session/{session_id}".format(
+"{endpoint}/{session_id}".format(
 endpoint=config.builddmaster.fetch_service_control_endpoint,
 session_id=session_id,
 )
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:requestProxyToken-function-refactor into launchpad:master

2024-03-11 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:requestProxyToken-function-refactor into launchpad:master.

Commit message:
Refactor _requestProxyToken to be aligned with _requestFetchServiceSession

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/462145
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:requestProxyToken-function-refactor into launchpad:master.
diff --git a/lib/lp/buildmaster/builderproxy.py b/lib/lp/buildmaster/builderproxy.py
index 1ac121f..75e049f 100644
--- a/lib/lp/buildmaster/builderproxy.py
+++ b/lib/lp/buildmaster/builderproxy.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2021 Canonical Ltd.  This software is licensed under the
+# Copyright 2015-2024 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Builder proxy support.
@@ -84,23 +84,11 @@ class BuilderProxyMixin:
 
 @defer.inlineCallbacks
 def _requestProxyToken(self):
-admin_username = _get_proxy_config(
+admin_username = _get_value_from_config(
 "builder_proxy_auth_api_admin_username"
 )
-if not admin_username:
-raise CannotBuild(
-"builder_proxy_auth_api_admin_username is not configured."
-)
-secret = _get_proxy_config("builder_proxy_auth_api_admin_secret")
-if not secret:
-raise CannotBuild(
-"builder_proxy_auth_api_admin_secret is not configured."
-)
-url = _get_proxy_config("builder_proxy_auth_api_endpoint")
-if not secret:
-raise CannotBuild(
-"builder_proxy_auth_api_endpoint is not configured."
-)
+secret = _get_value_from_config("builder_proxy_auth_api_admin_secret")
+url = _get_value_from_config("builder_proxy_auth_api_endpoint")
 timestamp = int(time.time())
 proxy_username = "{build_id}-{timestamp}".format(
 build_id=self.build.build_cookie, timestamp=timestamp
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:refactor-requestProxyToken-function into launchpad:master

2024-03-11 Thread Simone Pelosi
The proposal to merge ~pelpsi/launchpad:refactor-requestProxyToken-function 
into launchpad:master has been updated.

Status: Needs review => Rejected

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/462143
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:refactor-requestProxyToken-function into launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:refactor-requestProxyToken-function into launchpad:master

2024-03-11 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:refactor-requestProxyToken-function into launchpad:master.

Commit message:
Refactor requestProxyToken function to be aligned with 
requestFetchServiceSession

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/462143
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:refactor-requestProxyToken-function into launchpad:master.
diff --git a/lib/lp/buildmaster/builderproxy.py b/lib/lp/buildmaster/builderproxy.py
index 1ac121f..a1d475b 100644
--- a/lib/lp/buildmaster/builderproxy.py
+++ b/lib/lp/buildmaster/builderproxy.py
@@ -84,23 +84,11 @@ class BuilderProxyMixin:
 
 @defer.inlineCallbacks
 def _requestProxyToken(self):
-admin_username = _get_proxy_config(
+admin_username = _get_value_from_config(
 "builder_proxy_auth_api_admin_username"
 )
-if not admin_username:
-raise CannotBuild(
-"builder_proxy_auth_api_admin_username is not configured."
-)
-secret = _get_proxy_config("builder_proxy_auth_api_admin_secret")
-if not secret:
-raise CannotBuild(
-"builder_proxy_auth_api_admin_secret is not configured."
-)
-url = _get_proxy_config("builder_proxy_auth_api_endpoint")
-if not secret:
-raise CannotBuild(
-"builder_proxy_auth_api_endpoint is not configured."
-)
+secret = _get_value_from_config("builder_proxy_auth_api_admin_secret")
+url = _get_value_from_config("builder_proxy_auth_api_endpoint")
 timestamp = int(time.time())
 proxy_username = "{build_id}-{timestamp}".format(
 build_id=self.build.build_cookie, timestamp=timestamp
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~pelpsi/launchpad:fetch-service-session-API into launchpad:master

2024-03-06 Thread Simone Pelosi



Diff comments:

> diff --git a/lib/lp/buildmaster/builderproxy.py 
> b/lib/lp/buildmaster/builderproxy.py
> index be65e29..a1d475b 100644
> --- a/lib/lp/buildmaster/builderproxy.py
> +++ b/lib/lp/buildmaster/builderproxy.py
> @@ -52,26 +67,28 @@ class BuilderProxyMixin:
>  
> endpoint=_get_proxy_config("builder_proxy_auth_api_endpoint"),
>  token=token["username"],
>  )
> +elif fetch_service and _get_proxy_config("fetch_service_host"):
> +session = yield self._requestFetchServiceSession()
> +args["proxy_url"] = (
> +"http://{session_id}:{token}@{host}:{port}".format(
> +session_id=session["id"],
> +token=session["token"],
> +host=_get_proxy_config("fetch_service_host"),
> +port=_get_proxy_config("fetch_service_port"),
> +)
> +)
> +args["revocation_endpoint"] = "{endpoint}/session/{id}".format(
> +endpoint=_get_proxy_config("fetch_service_control_endpoint"),
> +id=session["id"],
> +)
>  
>  @defer.inlineCallbacks
>  def _requestProxyToken(self):
> -admin_username = _get_proxy_config(
> +admin_username = _get_value_from_config(
>  "builder_proxy_auth_api_admin_username"
>  )
> -if not admin_username:
> -raise CannotBuild(
> -"builder_proxy_auth_api_admin_username is not configured."
> -)
> -secret = _get_proxy_config("builder_proxy_auth_api_admin_secret")
> -if not secret:
> -raise CannotBuild(
> -"builder_proxy_auth_api_admin_secret is not configured."
> -)
> -url = _get_proxy_config("builder_proxy_auth_api_endpoint")
> -if not secret:
> -raise CannotBuild(
> -"builder_proxy_auth_api_endpoint is not configured."
> -)
> +secret = 
> _get_value_from_config("builder_proxy_auth_api_admin_secret")
> +url = _get_value_from_config("builder_proxy_auth_api_endpoint")

I added this one when I addressed Ines's comments :)

>  timestamp = int(time.time())
>  proxy_username = "{build_id}-{timestamp}".format(
>  build_id=self.build.build_cookie, timestamp=timestamp
> diff --git a/lib/lp/buildmaster/tests/fetchservice.py 
> b/lib/lp/buildmaster/tests/fetchservice.py
> new file mode 100644
> index 000..6b984d0
> --- /dev/null
> +++ b/lib/lp/buildmaster/tests/fetchservice.py
> @@ -0,0 +1,122 @@
> +# Copyright 2015-2024 Canonical Ltd.  This software is licensed under the
> +# GNU Affero General Public License version 3 (see the file LICENSE).
> +
> +"""Fixtures for dealing with the build time Fetch Service http proxy."""
> +
> +import json
> +import uuid
> +from textwrap import dedent
> +from urllib.parse import urlsplit
> +
> +import fixtures
> +from testtools.matchers import Equals, HasLength, MatchesStructure
> +from twisted.internet import defer, endpoints, reactor
> +from twisted.python.compat import nativeString
> +from twisted.web import resource, server
> +
> +from lp.services.config import config
> +
> +
> +class FetchServiceAuthAPITokensResource(resource.Resource):
> +"""A test session resource for the fetch service authentication API."""
> +
> +isLeaf = True
> +
> +def __init__(self):
> +resource.Resource.__init__(self)
> +self.requests = []
> +
> +def render_POST(self, request):
> +content = json.loads(request.content.read().decode("UTF-8"))
> +self.requests.append(
> +{
> +"method": request.method,
> +"uri": request.uri,
> +"headers": dict(request.requestHeaders.getAllRawHeaders()),
> +"json": content,
> +}
> +)
> +return json.dumps(
> +{
> +"id": "1",
> +"token": uuid.uuid4().hex,
> +}
> +).encode("UTF-8")
> +
> +
> +class InProcessFetchServiceAuthAPIFixture(fixtures.Fixture):
> +"""A fixture that mocks the Fetch Service authentication API.
> +
> +Users of this fixture must call the `start` method, which returns a
> +`Deferred`, and arrange for that to get back to the reactor.  This is
> +necessary because the basic fixture API does not allow `setUp` to return
> +anything.  For example:
> +
> +class TestSomething(TestCase):
> +
> +run_tests_with = AsynchronousDeferredRunTest.make_factory(
> +timeout=30)
> +
> +@defer.inlineCallbacks
> +def setUp(self):
> +super().setUp()
> +yield self.useFixture(
> +InProcessFetchServiceAuthAPIFixture()
> +).start()
> +"""
> +
> +@defer.inlineCallbacks
> +def start(self):
> +root = 

Re: [Launchpad-reviewers] [Merge] ~pelpsi/launchpad:fetch-service-session-API into launchpad:master

2024-03-05 Thread Simone Pelosi



Diff comments:

> diff --git a/lib/lp/buildmaster/downloader.py 
> b/lib/lp/buildmaster/downloader.py
> index fc16852..cee308a 100644
> --- a/lib/lp/buildmaster/downloader.py
> +++ b/lib/lp/buildmaster/downloader.py
> @@ -94,3 +110,24 @@ class RequestProcess(AMPChild):
>  )
>  response.raise_for_status()
>  return response.json()
> +
> +@RequestFetchServiceSessionCommand.responder
> +def requestFetchServiceSessionCommand(
> +self, url, auth_header, proxy_username
> +):
> +with Session() as session:
> +session.trust_env = False
> +# XXX pelpsi 2024-02-28: should take the same

I updated the comment, Claudio clarified some bit :)

> +# json body? From ST108 we should provide
> +# {
> +#   "timeout": ,// session timeout in 
> seconds
> +#   "policy":// "strict" or 
> "permissive"
> +# }
> +response = session.post(
> +url,
> +headers={"Authorization": auth_header},
> +json={"username": proxy_username},
> +)
> +print(" CI SIAMO ")
> +response.raise_for_status()
> +return response.json()


-- 
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/461721
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:fetch-service-session-API into launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~pelpsi/launchpad:fetch-service-session-API into launchpad:master

2024-03-04 Thread Simone Pelosi
Thank you for the review Ines, I'm so sorry I forgot to push the commit in 
which I removed all the debugging stuff or useless comments :P
-- 
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/461721
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:fetch-service-session-API into launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~pelpsi/launchpad:fetch-service-session-API into launchpad:master

2024-03-04 Thread Simone Pelosi



Diff comments:

> diff --git a/lib/lp/buildmaster/downloader.py 
> b/lib/lp/buildmaster/downloader.py
> index fc16852..cee308a 100644
> --- a/lib/lp/buildmaster/downloader.py
> +++ b/lib/lp/buildmaster/downloader.py
> @@ -94,3 +110,24 @@ class RequestProcess(AMPChild):
>  )
>  response.raise_for_status()
>  return response.json()
> +
> +@RequestFetchServiceSessionCommand.responder
> +def requestFetchServiceSessionCommand(
> +self, url, auth_header, proxy_username
> +):
> +with Session() as session:
> +session.trust_env = False
> +# XXX pelpsi 2024-02-28: should take the same

https://docs.google.com/document/d/1Ta0THOsHLwbOA6H7ewHa-6s2GtZRWxvvtiMKFk5jiq8/edit
 from here I can see that the API take these two params as input, it's not 
clear if they are mandatory or not. I should ask to Claudio to clarify that.

> +# json body? From ST108 we should provide
> +# {
> +#   "timeout": ,// session timeout in 
> seconds
> +#   "policy":// "strict" or 
> "permissive"
> +# }
> +response = session.post(
> +url,
> +headers={"Authorization": auth_header},
> +json={"username": proxy_username},
> +)
> +print(" CI SIAMO ")
> +response.raise_for_status()
> +return response.json()
> diff --git a/lib/lp/snappy/tests/test_snapbuildbehaviour.py 
> b/lib/lp/snappy/tests/test_snapbuildbehaviour.py
> index 5ec5804..45ee8c8 100644
> --- a/lib/lp/snappy/tests/test_snapbuildbehaviour.py
> +++ b/lib/lp/snappy/tests/test_snapbuildbehaviour.py
> @@ -296,6 +317,85 @@ class TestAsyncSnapBuildBehaviour(StatsMixin, 
> TestSnapBuildBehaviourBase):
>  )
>  
>  @defer.inlineCallbacks
> +def test_requestFetchServiceSession_unconfigured(self):
> +self.pushConfig("builddmaster", fetch_service_host=None)
> +self.useFixture(
> +FeatureFixture({SNAP_USE_FETCH_SERVICE_FEATURE_FLAG: "on"})

Yep, it's right but I don't know if it makes sense to add a test on a feature 
flag, what do you think? I think that I can add it with a comment to remove it 
in future.

> +)
> +snap = self.factory.makeSnap(use_fetch_service=True)
> +request = self.factory.makeSnapBuildRequest(snap=snap)
> +job = self.makeJob(snap=snap, build_request=request)
> +with dbuser(config.builddmaster.dbuser):
> +args = yield job.extraBuildArgs()
> +self.assertEqual([], self.fetch_service_api.tokens.requests)
> +self.assertNotIn("proxy_url", args)
> +self.assertNotIn("revocation_endpoint", args)
> +
> +@defer.inlineCallbacks
> +def test_requestFetchServiceSession_no_secret(self):
> +self.pushConfig(
> +"builddmaster", fetch_service_auth_api_admin_secret=None
> +)
> +self.useFixture(
> +FeatureFixture({SNAP_USE_FETCH_SERVICE_FEATURE_FLAG: "on"})
> +)
> +snap = self.factory.makeSnap(use_fetch_service=True)
> +request = self.factory.makeSnapBuildRequest(snap=snap)
> +job = self.makeJob(snap=snap, build_request=request)
> +expected_exception_msg = (
> +"fetch_service_auth_api_admin_secret is not configured."
> +)
> +with ExpectedException(CannotBuild, expected_exception_msg):
> +yield job.extraBuildArgs()
> +
> +@defer.inlineCallbacks
> +def test_requestFetchServiceSession(self):
> +self.useFixture(
> +FeatureFixture({SNAP_USE_FETCH_SERVICE_FEATURE_FLAG: "on"})
> +)
> +snap = self.factory.makeSnap(use_fetch_service=True)
> +request = self.factory.makeSnapBuildRequest(snap=snap)
> +job = self.makeJob(snap=snap, build_request=request)
> +yield job.extraBuildArgs()
> +expected_uri = urlsplit(
> +config.builddmaster.fetch_service_auth_api_endpoint
> +).path.encode("UTF-8")
> +request_matcher = MatchesDict(
> +{
> +"method": Equals(b"POST"),
> +"uri": Equals(expected_uri),
> +"headers": ContainsDict(
> +{
> +b"Authorization": MatchesListwise(
> +[
> +Equals(
> +b"Basic "
> ++ base64.b64encode(
> +b"admin-launchpad.test:admin-secret"
> +)
> +)
> +]
> +),
> +b"Content-Type": MatchesListwise(
> +[
> +Equals(b"application/json"),
> +]
> +  

[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:request-token-and-session-from-fetch-service into launchpad:master

2024-03-04 Thread Simone Pelosi
The proposal to merge 
~pelpsi/launchpad:request-token-and-session-from-fetch-service into 
launchpad:master has been updated.

Status: Work in progress => Rejected

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/461586
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:request-token-and-session-from-fetch-service into 
launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:fetch-service-session-API into launchpad:master

2024-03-04 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/launchpad:fetch-service-session-API 
into launchpad:master with 
~ines-almeida/launchpad:fetch-service-option-model-update as a prerequisite.

Commit message:
Add fetch service session API

Update BuilderProxyMixin class to switch between
Fetch Service and classic Builder Proxy depending on 
use_fetch_service flag.
Add test suite for Fetch Service and fetchservice.py mock class
for API.
Add Fetch Service API information on schema-lazr.conf.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/461721
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:fetch-service-session-API into launchpad:master.
diff --git a/lib/lp/buildmaster/builderproxy.py b/lib/lp/buildmaster/builderproxy.py
index be65e29..4f249a7 100644
--- a/lib/lp/buildmaster/builderproxy.py
+++ b/lib/lp/buildmaster/builderproxy.py
@@ -20,7 +20,10 @@ from typing import Dict, Generator
 
 from twisted.internet import defer
 
-from lp.buildmaster.downloader import RequestProxyTokenCommand
+from lp.buildmaster.downloader import (
+RequestFetchServiceSessionCommand,
+RequestProxyTokenCommand,
+)
 from lp.buildmaster.interfaces.builder import CannotBuild
 from lp.buildmaster.interfaces.buildfarmjobbehaviour import BuildArgs
 from lp.services.config import config
@@ -36,9 +39,16 @@ class BuilderProxyMixin:
 
 @defer.inlineCallbacks
 def addProxyArgs(
-self, args: BuildArgs, allow_internet: bool = True
+self,
+args: BuildArgs,
+allow_internet: bool = True,
+fetch_service: bool = False,
 ) -> Generator[None, Dict[str, str], None]:
-if _get_proxy_config("builder_proxy_host") and allow_internet:
+if (
+not fetch_service
+and _get_proxy_config("builder_proxy_host")
+and allow_internet
+):
 token = yield self._requestProxyToken()
 args["proxy_url"] = (
 "http://{username}:{password}@{host}:{port}".format(
@@ -52,6 +62,25 @@ class BuilderProxyMixin:
 endpoint=_get_proxy_config("builder_proxy_auth_api_endpoint"),
 token=token["username"],
 )
+if (
+fetch_service
+and _get_proxy_config("fetch_service_host")
+and allow_internet
+):
+# http://:@:9988/
+token = yield self._requestFetchServiceSession()
+args["proxy_url"] = (
+"http://{session_id}:{token}@{host}:{port}".format(
+session_id=token["id"],
+token=token["token"],
+host=_get_proxy_config("fetch_service_host"),
+port=_get_proxy_config("fetch_service_port"),
+)
+)
+args["revocation_endpoint"] = "{endpoint}/session/{id}".format(
+endpoint=_get_proxy_config("fetch_service_auth_api_endpoint"),
+id=token["id"],
+)
 
 @defer.inlineCallbacks
 def _requestProxyToken(self):
@@ -86,3 +115,39 @@ class BuilderProxyMixin:
 proxy_username=proxy_username,
 )
 return token
+
+@defer.inlineCallbacks
+def _requestFetchServiceSession(self):
+# This is a different function if we have the needs to
+# differentiate more the behavior.
+admin_username = _get_proxy_config(
+"fetch_service_auth_api_admin_username"
+)
+if not admin_username:
+raise CannotBuild(
+"fetch_service_auth_api_admin_username is not configured."
+)
+secret = _get_proxy_config("fetch_service_auth_api_admin_secret")
+if not secret:
+raise CannotBuild(
+"fetch_service_auth_api_admin_secret is not configured."
+)
+url = _get_proxy_config("fetch_service_auth_api_endpoint")
+if not secret:
+raise CannotBuild(
+"fetch_service_auth_api_endpoint is not configured."
+)
+timestamp = int(time.time())
+proxy_username = "{build_id}-{timestamp}".format(
+build_id=self.build.build_cookie, timestamp=timestamp
+)
+auth_string = f"{admin_username}:{secret}".strip()
+auth_header = b"Basic " + base64.b64encode(auth_string.encode("ASCII"))
+
+token = yield self._worker.process_pool.doWork(
+RequestFetchServiceSessionCommand,
+url=url,
+auth_header=auth_header,
+proxy_username=proxy_username,

Re: [Launchpad-reviewers] [Merge] ~pelpsi/lp-signing:update-development-documentation into lp-signing:master

2024-03-04 Thread Simone Pelosi



Diff comments:

> diff --git a/README.rst b/README.rst
> index 5fc6b9b..4e52196 100644
> --- a/README.rst
> +++ b/README.rst
> @@ -38,6 +38,12 @@ Generate another key pair, and add the private half to 
> ``private_keys``
>  
>  $ env/bin/lp-signing generate-key-pair
>  
> +If you want to communicate with the lp-signing server, 
> +add your client to the signing service::
> +
> +$ source env/bin/activate
> +$ lp-signing register-client  

base64-encoded NaCl public key, let me add this information to the doc

> +
>  Start the server::
>  
>  $ make run


-- 
https://code.launchpad.net/~pelpsi/lp-signing/+git/lp-signing/+merge/461650
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lp-signing:update-development-documentation into lp-signing:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~pelpsi/launchpad-buildd:qastaging-documentation-improvement into launchpad-buildd:master

2024-03-01 Thread Simone Pelosi



Diff comments:

> diff --git a/docs/how-to/deployment.rst b/docs/how-to/deployment.rst
> index 7365bee..fbe4b22 100644
> --- a/docs/how-to/deployment.rst
> +++ b/docs/how-to/deployment.rst
> @@ -42,11 +42,14 @@ Testing on qastaging
> 
> `__.
>  
>  #. Run ``mojo run -m manifest-rebuild-images`` in the management environment
> -   (``stg-vbuilder@launchpad-bastion-ps5``) to start rebuilding images.
> +   (``stg-vbuilder-qastaging@launchpad-bastion-ps5``) to start rebuilding 
> images.
> After a minute or so, ``juju status glance-simplestreams-sync-\*`` will
> show "Synchronising images"; once this says "Sync completed", images have
> been rebuilt.
>  
> +   Note that if ``mojo run -m manifest-rebuild-images`` fails, run ``mojo 
> run``
> +   instead.

Because it may happen that some glance-simplestreams-sync unit is in unknown 
state: thus means, from what I understood, that the images that we have in 
OpenStack for the affected unit are not updated. This will cause an error when 
you try to rebuild images: https://pastebin.canonical.com/p/ChfGwsQNGJ/ 
blocking the execution of the script.

This doesn't happen if you use `mojo run`

> +
>  #. Builders will get the new image after they finish their next build (or
> are disabled) and go through being reset.  Since qastaging's build farm
> is typically mostly idle, you can use ``manage-builders -l qastaging


-- 
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/461052
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad-buildd:qastaging-documentation-improvement into 
launchpad-buildd:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/lp-signing:update-development-documentation into lp-signing:master

2024-03-01 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/lp-signing:update-development-documentation into lp-signing:master.

Commit message:
Add register-client command to the documentation

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/lp-signing/+git/lp-signing/+merge/461650
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lp-signing:update-development-documentation into lp-signing:master.
diff --git a/README.rst b/README.rst
index 5fc6b9b..4e52196 100644
--- a/README.rst
+++ b/README.rst
@@ -38,6 +38,12 @@ Generate another key pair, and add the private half to ``private_keys``
 
 $ env/bin/lp-signing generate-key-pair
 
+If you want to communicate with the lp-signing server, 
+add your client to the signing service::
+
+$ source env/bin/activate
+$ lp-signing register-client  
+
 Start the server::
 
 $ make run
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:create-new-4096-key-for-archives-with-1024-key into launchpad:master

2024-03-01 Thread Simone Pelosi
The proposal to merge 
~pelpsi/launchpad:create-new-4096-key-for-archives-with-1024-key into 
launchpad:master has been updated.

Description changed to:

Required for LP130 - ESM authorization for archive snapshots: 
https://docs.google.com/document/d/1O7nQTjlASd6T_i3maRJxTBVXfWm-2sPYEwJj-8qm9cY/edit

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/461648
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:create-new-4096-key-for-archives-with-1024-key into 
launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:create-new-4096-key-for-archives-with-1024-key into launchpad:master

2024-03-01 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:create-new-4096-key-for-archives-with-1024-key into 
launchpad:master.

Commit message:
Add logic to update 1024 PPAs keys

Cronscript to generate new 4096-bit RSA signing keys for the affected
PPAs (the ones with 1024-bit key) and add a row to the signingkey table
with the information about the newly generated key.
The new key will be generated for the default PPA and then propagated
to the other PPAs beloning to the same owner.
Add rows to the archivesigningkey containing updated PPAs
(i.e., one row per signing key-archive combination).
Also add information regarding the new keys to the gpgkey table.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/461648
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:create-new-4096-key-for-archives-with-1024-key into 
launchpad:master.
diff --git a/cronscripts/ppa-update-keys.py b/cronscripts/ppa-update-keys.py
new file mode 100755
index 000..2ab1ea5
--- /dev/null
+++ b/cronscripts/ppa-update-keys.py
@@ -0,0 +1,15 @@
+#!/usr/bin/python3 -S
+#
+# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""A cron script that generate missing PPA signing keys."""
+
+import _pythonpath  # noqa: F401
+
+from lp.services.config import config
+from lp.soyuz.scripts.ppakeyupdater import PPAKeyUpdater
+
+if __name__ == "__main__":
+script = PPAKeyUpdater("ppa-generate-keys", config.archivepublisher.dbuser)
+script.lock_and_run()
diff --git a/lib/lp/archivepublisher/archivegpgsigningkey.py b/lib/lp/archivepublisher/archivegpgsigningkey.py
index 722cecd..e1b880c 100644
--- a/lib/lp/archivepublisher/archivegpgsigningkey.py
+++ b/lib/lp/archivepublisher/archivegpgsigningkey.py
@@ -30,7 +30,7 @@ from lp.archivepublisher.run_parts import find_run_parts_dir, run_parts
 from lp.registry.interfaces.gpg import IGPGKeySet
 from lp.services.config import config
 from lp.services.features import getFeatureFlag
-from lp.services.gpg.interfaces import IGPGHandler, IPymeKey
+from lp.services.gpg.interfaces import GPGKeyAlgorithm, IGPGHandler, IPymeKey
 from lp.services.osutils import remove_if_exists
 from lp.services.propertycache import cachedproperty, get_property_cache
 from lp.services.signing.enums import (
@@ -39,6 +39,7 @@ from lp.services.signing.enums import (
 SigningMode,
 )
 from lp.services.signing.interfaces.signingkey import (
+IArchiveSigningKeySet,
 ISigningKey,
 ISigningKeySet,
 )
@@ -330,6 +331,80 @@ class ArchiveGPGSigningKey(SignableArchive):
 signing_key, async_keyserver=async_keyserver
 )
 
+def generate4096SigningKey(self, log=None):
+"""See `IArchiveGPGSigningKey`."""
+assert (
+self.archive.signing_key_fingerprint is not None
+), "Archive doesn't have key to update."
+old_gpg_key = getUtility(IGPGKeySet).getByFingerprint(
+self.archive.signing_key_fingerprint
+)
+assert old_gpg_key.keysize == 1024, "Archive already has 4096 key."
+
+default_ppa = (
+self.archive.owner.archive if self.archive.is_ppa else self.archive
+)
+if self.archive != default_ppa:
+
+def propagate_key(archive_signing_key):
+getUtility(IArchiveSigningKeySet).create(
+self.archive, None, archive_signing_key
+)
+del get_property_cache(self.archive).signing_key
+del get_property_cache(self.archive).signing_key_display_name
+
+default_signing_key = getUtility(
+IArchiveSigningKeySet
+).getSigningKey(SigningKeyType.OPENPGP, default_ppa, None)
+if default_signing_key is None:
+# Recursively update default_ppa key
+IArchiveGPGSigningKey(default_ppa).upgradeSigningKey(log=log)
+propagate_key(default_signing_key)
+return
+
+key_displayname = (
+"Launchpad PPA for %s" % self.archive.owner.displayname
+)
+key_owner = getUtility(ILaunchpadCelebrities).ppa_key_guard
+try:
+signing_key = getUtility(ISigningKeySet).generate(
+SigningKeyType.OPENPGP,
+key_displayname,
+openpgp_key_algorithm=OpenPGPKeyAlgorithm.RSA,
+length=4096,
+)
+getUtility(IArchiveSigningKeySet).create(
+self.archive, None, signing_key
+)
+getUtility(IGPGKeySet).new(
+key_owner,
+signing_key.fingerprint[-8:],
+signing_key.fingerp

[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:request-token-and-session-from-fetch-service into launchpad:master

2024-02-29 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:request-token-and-session-from-fetch-service into 
launchpad:master with ~ines-almeida/launchpad:fetch-service-option-model-update 
as a prerequisite.

Commit message:
Request fetch service session

NOTE: THIS IS A WIP! This message will be updated!

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/461586
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:request-token-and-session-from-fetch-service into 
launchpad:master.
diff --git a/lib/lp/buildmaster/builderproxy.py b/lib/lp/buildmaster/builderproxy.py
index be65e29..6857305 100644
--- a/lib/lp/buildmaster/builderproxy.py
+++ b/lib/lp/buildmaster/builderproxy.py
@@ -20,7 +20,10 @@ from typing import Dict, Generator
 
 from twisted.internet import defer
 
-from lp.buildmaster.downloader import RequestProxyTokenCommand
+from lp.buildmaster.downloader import (
+RequestFetchServiceSessionCommand,
+RequestProxyTokenCommand,
+)
 from lp.buildmaster.interfaces.builder import CannotBuild
 from lp.buildmaster.interfaces.buildfarmjobbehaviour import BuildArgs
 from lp.services.config import config
@@ -36,9 +39,16 @@ class BuilderProxyMixin:
 
 @defer.inlineCallbacks
 def addProxyArgs(
-self, args: BuildArgs, allow_internet: bool = True
+self,
+args: BuildArgs,
+allow_internet: bool = True,
+fetch_service: bool = False,
 ) -> Generator[None, Dict[str, str], None]:
-if _get_proxy_config("builder_proxy_host") and allow_internet:
+if (
+not fetch_service
+and _get_proxy_config("builder_proxy_host")
+and allow_internet
+):
 token = yield self._requestProxyToken()
 args["proxy_url"] = (
 "http://{username}:{password}@{host}:{port}".format(
@@ -52,6 +62,25 @@ class BuilderProxyMixin:
 endpoint=_get_proxy_config("builder_proxy_auth_api_endpoint"),
 token=token["username"],
 )
+if (
+fetch_service
+and _get_proxy_config("fetch_service_host")
+and allow_internet
+):
+# http://:@:9988/
+token = yield self._requestFetchServiceSession()
+args["proxy_url"] = (
+"http://{session_id}:{token}@{host}:{port}".format(
+session_id=token["id"],
+token=token["token"],
+host=_get_proxy_config("fetch_service_host"),
+port=_get_proxy_config("fetch_service_port"),
+)
+)
+args["revocation_endpoint"] = "{endpoint}/{token}".format(
+endpoint=_get_proxy_config("fetch_service_auth_api_endpoint"),
+token=token["username"],
+)
 
 @defer.inlineCallbacks
 def _requestProxyToken(self):
@@ -86,3 +115,39 @@ class BuilderProxyMixin:
 proxy_username=proxy_username,
 )
 return token
+
+@defer.inlineCallbacks
+def _requestFetchServiceSession(self):
+# This is a different function if we have the needs to
+# differentiate more the behavior.
+admin_username = _get_proxy_config(
+"fetch_service_auth_api_admin_username"
+)
+if not admin_username:
+raise CannotBuild(
+"fetch_service_auth_api_admin_username is not configured."
+)
+secret = _get_proxy_config("fetch_service_auth_api_admin_secret")
+if not secret:
+raise CannotBuild(
+"fetch_service_auth_api_admin_secret is not configured."
+)
+url = _get_proxy_config("fetch_service_auth_api_endpoint")
+if not secret:
+raise CannotBuild(
+"fetch_service_auth_api_endpoint is not configured."
+)
+timestamp = int(time.time())
+proxy_username = "{build_id}-{timestamp}".format(
+build_id=self.build.build_cookie, timestamp=timestamp
+)
+auth_string = f"{admin_username}:{secret}".strip()
+auth_header = b"Basic " + base64.b64encode(auth_string.encode("ASCII"))
+
+token = yield self._worker.process_pool.doWork(
+RequestFetchServiceSessionCommand,
+url=url,
+auth_header=auth_header,
+proxy_username=proxy_username,
+)
+return token
diff --git a/lib/lp/buildmaster/downloader.py b/lib/lp/buildmaster/downloader.py
index fc16852..ecc10f9 100644
--- a/lib/lp/buildmaster

[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:request-token-and-session-from-fetch-service into launchpad:master

2024-02-29 Thread Simone Pelosi
The proposal to merge 
~pelpsi/launchpad:request-token-and-session-from-fetch-service into 
launchpad:master has been updated.

Status: Needs review => Work in progress

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/461586
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:request-token-and-session-from-fetch-service into 
launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:request-token-and-session-from-fetch-service into launchpad:master

2024-02-29 Thread Simone Pelosi
The proposal to merge 
~pelpsi/launchpad:request-token-and-session-from-fetch-service into 
launchpad:master has been updated.

Status: Work in progress => Superseded

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/461458
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:request-token-and-session-from-fetch-service into 
launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~ines-almeida/launchpad:fetch-service-option-db-update into launchpad:db-devel

2024-02-27 Thread Simone Pelosi
Review: Approve


-- 
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/461264
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ines-almeida/launchpad:fetch-service-option-db-update into launchpad:db-devel.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-buildd:qastaging-documentation-improvement into launchpad-buildd:master

2024-02-22 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad-buildd:qastaging-documentation-improvement into 
launchpad-buildd:master.

Commit message:
Improve documentation for qastaging deployment

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/461052
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad-buildd:qastaging-documentation-improvement into 
launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 8bddfae..f261f59 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+launchpad-buildd (237) UNRELEASED; urgency=medium
+
+  [ Simone Pelosi ]
+  * Improve documentation for qastaging deployment.
+
+ -- Simone Pelosi   Thu, 22 Feb 2024 17:16:55 +0100
+
 launchpad-buildd (236) focal; urgency=medium
 
   [ Colin Watson ]
diff --git a/docs/how-to/deployment.rst b/docs/how-to/deployment.rst
index 7365bee..fbe4b22 100644
--- a/docs/how-to/deployment.rst
+++ b/docs/how-to/deployment.rst
@@ -42,11 +42,14 @@ Testing on qastaging
<https://launchpad.net/~launchpad/+archive/ubuntu/buildd-staging/+packages>`__.
 
 #. Run ``mojo run -m manifest-rebuild-images`` in the management environment
-   (``stg-vbuilder@launchpad-bastion-ps5``) to start rebuilding images.
+   (``stg-vbuilder-qastaging@launchpad-bastion-ps5``) to start rebuilding images.
After a minute or so, ``juju status glance-simplestreams-sync-\*`` will
show "Synchronising images"; once this says "Sync completed", images have
been rebuilt.
 
+   Note that if ``mojo run -m manifest-rebuild-images`` fails, run ``mojo run``
+   instead.
+
 #. Builders will get the new image after they finish their next build (or
are disabled) and go through being reset.  Since qastaging's build farm
is typically mostly idle, you can use ``manage-builders -l qastaging
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~ines-almeida/launchpad:frontpage-revamp-change-layout into ~ines-almeida/launchpad:frontpage-revamp-remove-top-project

2024-02-21 Thread Simone Pelosi
It looks good! Could you also update copyright string? (from 2004-2023 to 
2004-2024)
-- 
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/460819
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ines-almeida/launchpad:frontpage-revamp-change-layout into 
~ines-almeida/launchpad:frontpage-revamp-remove-top-project.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-buildd:release-236 into launchpad-buildd:master

2024-02-16 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/launchpad-buildd:release-236 into 
launchpad-buildd:master.

Commit message:
Release version 236

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/460671
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad-buildd:release-236 into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 3cce517..8bddfae 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-launchpad-buildd (236) UNRELEASED; urgency=medium
+launchpad-buildd (236) focal; urgency=medium
 
   [ Colin Watson ]
   * Add lxc.cgroup2.* configuration, for compatibility with future
@@ -14,11 +14,11 @@ launchpad-buildd (236) UNRELEASED; urgency=medium
   * Add support for snap components.
 Snap components are already built by our build jobs but not 
 added to `built files`. 
-Add `.comp` filetype to the filter in the `gatherResults` function
+Add `.comp` filetype to the filter in `gatherResults` function
 to process components correctly. 
 Snap components and `.comp` file type reference: SD149
 
- -- Colin Watson   Thu, 16 Nov 2023 16:06:07 +
+ -- Simone Pelosi   Fri, 16 Feb 2024 10:21:07 +0100
 
 launchpad-buildd (235) focal; urgency=medium
 
diff --git a/docs/conf.py b/docs/conf.py
index fa1050a..c81ae4d 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -22,7 +22,7 @@ copyright = "2009-2022, Canonical Ltd"
 author = "Launchpad developers"
 
 # The full version, including alpha/beta/rc tags
-release = "235"
+release = "236"
 
 
 # -- General configuration ---
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:copy-archive-publisher-missing-umask into launchpad:master

2024-02-14 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:copy-archive-publisher-missing-umask into launchpad:master.

Commit message:
Add umask 022 before publish-ftpmaster.py call

umask 022 is required to fix the following error:
`Queue item ignored: Bad umask; expected 022, got 002`

Support request: 
https://chat.canonical.com/canonical/pl/uidssikjuiby5ja5p189cjz15y

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/460488
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:copy-archive-publisher-missing-umask into launchpad:master.
diff --git a/charm/launchpad-copy-archive-publisher/templates/crontab.j2 b/charm/launchpad-copy-archive-publisher/templates/crontab.j2
index 99eb759..bf2502b 100644
--- a/charm/launchpad-copy-archive-publisher/templates/crontab.j2
+++ b/charm/launchpad-copy-archive-publisher/templates/crontab.j2
@@ -4,7 +4,7 @@ MAILTO={{ cron_mailto }}
 LPCONFIG=launchpad-copy-archive-publisher
 
 {% if active -%}
-*/5 * * * * {{ code_dir }}/cronscripts/publish-ftpmaster.py --all-derived -vv >> {{ logs_dir }}/derived-publish-ftpmaster.log 2>&1
+*/5 * * * * umask 022; {{ code_dir }}/cronscripts/publish-ftpmaster.py --all-derived -vv >> {{ logs_dir }}/derived-publish-ftpmaster.log 2>&1
 
 10 */6 * * * {{ code_dir }}/scripts/process-death-row.py --all-derived -q --log-file=DEBUG:{{ logs_dir }}/derived-process-death-row.log
 
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~pelpsi/launchpad-buildd:snap-components-support into launchpad-buildd:master

2024-02-01 Thread Simone Pelosi
Thank you for you review! Sure, I was not so clear. Test here is testing a 
build with a component and checks if the component is added correctly to the 
waiting files.

I came up with that solution when Dimitri (xnox) asked why the `.comp` file 
generated by this build 
https://launchpad.net/~canonical-kernel-snaps/canonical-kernel-snaps/+snap/hwe-kernel-test-component/+build/2376991
 didn't appear on `Built files`. 

So I started the investigation and I saw (from the build logs) that the 
component was generated correctly:
```
Packed component 'iwlwifi' to 'pc-kernel+iwlwifi_0.1.comp'.
Created component packages
```

So I noticed that when we are gathering the results from the build and we are 
adding them to the file cache we are filtering the results, for this reason I 
added the new suffix.
-- 
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/459807
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad-buildd:snap-components-support into launchpad-buildd:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-buildd:snap-components-support into launchpad-buildd:master

2024-02-01 Thread Simone Pelosi
The proposal to merge ~pelpsi/launchpad-buildd:snap-components-support into 
launchpad-buildd:master has been updated.

Commit message changed to:

Added support for snap components

`.comp` files must be added to file cache.

Snap components and `.comp` file type: 
https://docs.google.com/document/d/1YEGsTgpbtmy3QO549mgTLBbTFQegl8_LVUVbQ_z9tPs/edit

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/459807
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad-buildd:snap-components-support into launchpad-buildd:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-buildd:snap-components-support into launchpad-buildd:master

2024-02-01 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad-buildd:snap-components-support into launchpad-buildd:master.

Commit message:
Added support for snap components

`.comp` files must be added to file cache.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/459807
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad-buildd:snap-components-support into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 4849b34..e8bf844 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,6 @@
 launchpad-buildd (236) UNRELEASED; urgency=medium
 
+  [ Colin Watson ]
   * Add lxc.cgroup2.* configuration, for compatibility with future
 environments where we use unified cgroup2.  (However, we should keep
 using systemd.unified_cgroup_hierarchy=false until we drop support for
@@ -9,6 +10,9 @@ launchpad-buildd (236) UNRELEASED; urgency=medium
 separately.
   * Document deployment to qastaging in place of dogfood.
 
+  [Simone Pelosi]
+  * Add support for snap components. 
+
  -- Colin Watson   Thu, 16 Nov 2023 16:06:07 +
 
 launchpad-buildd (235) focal; urgency=medium
diff --git a/lpbuildd/snap.py b/lpbuildd/snap.py
index d922242..d840093 100644
--- a/lpbuildd/snap.py
+++ b/lpbuildd/snap.py
@@ -139,7 +139,7 @@ class SnapBuildManager(BuildManagerProxyMixin, DebianBuildManager):
 if self.backend.islink(path):
 continue
 if entry.endswith(
-(".snap", ".manifest", ".debug", ".dpkg.yaml")
+(".snap", ".manifest", ".debug", ".dpkg.yaml", ".comp")
 ):
 self.addWaitingFileFromBackend(path)
 if self.build_source_tarball:
diff --git a/lpbuildd/tests/test_snap.py b/lpbuildd/tests/test_snap.py
index 0e44093..42834a3 100644
--- a/lpbuildd/tests/test_snap.py
+++ b/lpbuildd/tests/test_snap.py
@@ -255,6 +255,78 @@ class TestSnapBuildManagerIteration(TestCase):
 self.assertFalse(self.builder.wasCalled("buildFail"))
 
 @defer.inlineCallbacks
+def test_iterate_with_components(self):
+# The build manager iterates a build that uploads components from
+# start to finish.
+args = {
+"git_repository": "https://git.launchpad.dev/~example/+git/snap;,
+"git_path": "master",
+}
+expected_options = [
+"--git-repository",
+"https://git.launchpad.dev/~example/+git/snap;,
+"--git-path",
+"master",
+]
+yield self.startBuild(args, expected_options)
+
+log_path = os.path.join(self.buildmanager._cachepath, "buildlog")
+with open(log_path, "w") as log:
+log.write("I am a build log.")
+
+self.buildmanager.backend.add_file(
+"/build/test-snap/test-snap_0_all.snap", b"I am a snap package."
+)
+self.buildmanager.backend.add_file(
+"/build/test-snap/test-snap_0_all.comp", b"I am a component."
+)
+
+# After building the package, reap processes.
+yield self.buildmanager.iterate(0)
+expected_command = [
+"sharepath/bin/in-target",
+"in-target",
+"scan-for-processes",
+"--backend=lxd",
+"--series=xenial",
+"--arch=i386",
+self.buildid,
+]
+self.assertEqual(SnapBuildState.BUILD_SNAP, self.getState())
+self.assertEqual(expected_command, self.buildmanager.commands[-1])
+self.assertNotEqual(
+self.buildmanager.iterate, self.buildmanager.iterators[-1]
+)
+self.assertFalse(self.builder.wasCalled("buildFail"))
+self.assertThat(
+self.builder,
+HasWaitingFiles.byEquality(
+{
+"test-snap_0_all.comp": b"I am a component.",
+"test-snap_0_all.snap": b"I am a snap package.",
+}
+),
+)
+
+# Control returns to the DebianBuildManager in the UMOUNT state.
+self.buildmanager.iterateReap(self.getState(), 0)
+expected_command = [
+"sharepath/bin/in-target",
+"in-target",
+"umount-chroot",
+"--backend=lxd",
+"--series=xenial",
+"--arch=i386",
+self.buildid,
+]
+self.assertEqual(SnapBuildStat

Re: [Launchpad-reviewers] [Merge] ~ines-almeida/launchpad:increase-unittest-fetch-timeout into launchpad:master

2024-01-18 Thread Simone Pelosi
Is this change related to flaky tests ? 
-- 
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/458930
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ines-almeida/launchpad:increase-unittest-fetch-timeout into launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~ines-almeida/launchpad:social-accounts-edit-view into launchpad:master

2024-01-12 Thread Simone Pelosi



Diff comments:

> diff --git a/lib/lp/registry/interfaces/socialaccount.py 
> b/lib/lp/registry/interfaces/socialaccount.py
> index 7e910cc..e8c219e 100644
> --- a/lib/lp/registry/interfaces/socialaccount.py
> +++ b/lib/lp/registry/interfaces/socialaccount.py
> @@ -40,6 +40,7 @@ class SocialPlatform(DBEnumeratedType):
>  The Social Account will hold Matrix account info.
>  """,
>  )
> +matrix_identity_fields = ["nickname", "network"]

I think that we can use the following approach for the moment and then replace 
it later, using a proper class for a given Social Platform storing all the 
specific information. I will update my MP too, with matrix_identity_fields.

>  
>  
>  # XXX pelpsi 2023-12-14 bug=760849: "beta" is a lie to get WADL generation


-- 
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/458537
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ines-almeida/launchpad:social-accounts-edit-view into launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~ines-almeida/launchpad:social-accounts-ui-display-accounts into launchpad:master

2024-01-11 Thread Simone Pelosi



Diff comments:

> diff --git a/lib/lp/app/browser/tales.py b/lib/lp/app/browser/tales.py
> index eb5cad2..862c0bb 100644
> --- a/lib/lp/app/browser/tales.py
> +++ b/lib/lp/app/browser/tales.py
> @@ -3049,3 +3050,27 @@ class IRCNicknameFormatterAPI(ObjectFormatterAPI):
>  self._context.nickname,
>  self._context.network,
>  ).escapedtext
> +
> +
> +@implementer(ITraversable)
> +class SocialAccountFormatterAPI(ObjectFormatterAPI):
> +"""Adapter from social account objects to a formatted string."""
> +
> +traversable_names = {
> +"formatted_displayname": "formatted_displayname",
> +}
> +
> +def formatted_displayname(self, view_name=None):
> +if self._context.platform == SocialPlatform.MATRIX:
> +nickname = self._context.identity.get("nickname")
> +network = self._context.identity.get("network")

Does it make sense here to check if nickname and network are != None ?

> +return structured(
> +dedent(
> +f"""\
> +{nickname}
> + on 
> +{network}
> +"""
> +),
> +).escapedtext
> +return None
> diff --git a/lib/lp/registry/templates/person-portlet-contact-details.pt 
> b/lib/lp/registry/templates/person-portlet-contact-details.pt
> index 9a45fd4..720415d 100644
> --- a/lib/lp/registry/templates/person-portlet-contact-details.pt
> +++ b/lib/lp/registry/templates/person-portlet-contact-details.pt
> @@ -200,6 +172,46 @@
>  
>
>  
> +  
> +  Social Accounts

I tested the UI locally and `Social Accounts` headers seems to get lost a bit 
among other headers and titles, is there a way to make it more prominent?

> +
> +  IRC:
> +
> +
> +  
> +
> +  
> +  
> +No IRC nicknames registered.
> +  
> +
> +
> +
> +  Jabber:
> +
> +  
> +  
> +
> +   +/>,
> +
> +
> +  No Jabber IDs registered.
> +
> +  
> +
> +
> + id="matrix-accounts">
> +  Matrix:
> +  
> +
> +  
> +  
> +No Matrix accounts registered.
> +  
> +
> +  
> +
>  
>  
>  


-- 
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/458449
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ines-almeida/launchpad:social-accounts-ui-display-accounts into 
launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:process-death-row-lockfile-in-use-exclude-hours into launchpad:master

2023-12-15 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:process-death-row-lockfile-in-use-exclude-hours into 
launchpad:master.

Commit message:
Lockfile in use by process-death-row-py `--all-derived`

We are calling `process-death-row.py --all-derived` every hour and
it shares the lockfile with `process-death-row.py -d ubuntu` that is
called every 6 hours. Thus it may happen that one of the two processes
finds the lockfile already in use.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/457633
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:process-death-row-lockfile-in-use-exclude-hours into 
launchpad:master.
diff --git a/charm/launchpad-ppa-publisher/templates/crontab.j2 b/charm/launchpad-ppa-publisher/templates/crontab.j2
index f4918ed..7096ac0 100644
--- a/charm/launchpad-ppa-publisher/templates/crontab.j2
+++ b/charm/launchpad-ppa-publisher/templates/crontab.j2
@@ -14,8 +14,8 @@ P3AROOT={{ ppa_archive_private_root }}
 17,47 * * * * nice -n 15 {{ code_dir }}/cronscripts/parse-ppa-apache-access-logs.py -q --log-file=INFO:{{ logs_dir }}/parse-ppa-apache-access-logs.log
 
 59 05  * * 0 {{ code_dir }}/cronscripts/publishing/cron.daily-ppa >> {{ logs_dir }}/cron.ppa.log 2>&1
-1 */6 * * * nice -n 17 {{ code_dir }}/scripts/process-death-row.py -d ubuntu --ppa -q --log-file=INFO:{{ logs_dir }}/process-death-row.log
-0 * * * * nice -n 17 {{ code_dir }}/scripts/process-death-row.py --all-derived --ppa -q --log-file=INFO:{{ logs_dir }}/derived-process-death-row.log
+0 */6 * * * nice -n 17 {{ code_dir }}/scripts/process-death-row.py -d ubuntu --ppa -q --log-file=INFO:{{ logs_dir }}/process-death-row.log
+0 1-5,7-11,13-17,19-23 * * * nice -n 17 {{ code_dir }}/scripts/process-death-row.py --all-derived --ppa -q --log-file=INFO:{{ logs_dir }}/derived-process-death-row.log
 */20 * * * * nice -n 12 ionice -c 2 -n 7 {{ code_dir }}/cronscripts/ppa-generate-keys.py -q --log-file=INFO:{{ logs_dir }}/ppa-generate-keys.log
 {% endif %}
 
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:process-death-row-lockfile-in-use into launchpad:master

2023-12-15 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:process-death-row-lockfile-in-use into launchpad:master.

Commit message:
Lockfile in use by process-death-row-py `--all-derived`

We are calling `process-death-row.py --all-derived` every hour and
it shares the lockfile with `process-death-row.py -d ubuntu` that is
called every 6 hours. Thus it may happen that one of the two processes
finds the lockfile already in use.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/457626
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:process-death-row-lockfile-in-use into launchpad:master.
diff --git a/charm/launchpad-ppa-publisher/templates/crontab.j2 b/charm/launchpad-ppa-publisher/templates/crontab.j2
index d9ae397..f4918ed 100644
--- a/charm/launchpad-ppa-publisher/templates/crontab.j2
+++ b/charm/launchpad-ppa-publisher/templates/crontab.j2
@@ -14,7 +14,7 @@ P3AROOT={{ ppa_archive_private_root }}
 17,47 * * * * nice -n 15 {{ code_dir }}/cronscripts/parse-ppa-apache-access-logs.py -q --log-file=INFO:{{ logs_dir }}/parse-ppa-apache-access-logs.log
 
 59 05  * * 0 {{ code_dir }}/cronscripts/publishing/cron.daily-ppa >> {{ logs_dir }}/cron.ppa.log 2>&1
-0 */6 * * * nice -n 17 {{ code_dir }}/scripts/process-death-row.py -d ubuntu --ppa -q --log-file=INFO:{{ logs_dir }}/process-death-row.log
+1 */6 * * * nice -n 17 {{ code_dir }}/scripts/process-death-row.py -d ubuntu --ppa -q --log-file=INFO:{{ logs_dir }}/process-death-row.log
 0 * * * * nice -n 17 {{ code_dir }}/scripts/process-death-row.py --all-derived --ppa -q --log-file=INFO:{{ logs_dir }}/derived-process-death-row.log
 */20 * * * * nice -n 12 ionice -c 2 -n 7 {{ code_dir }}/cronscripts/ppa-generate-keys.py -q --log-file=INFO:{{ logs_dir }}/ppa-generate-keys.log
 {% endif %}
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~pelpsi/launchpad:social-account-interface-and-implementation into launchpad:master

2023-12-14 Thread Simone Pelosi



Diff comments:

> diff --git a/lib/lp/registry/interfaces/socialaccount.py 
> b/lib/lp/registry/interfaces/socialaccount.py
> new file mode 100644
> index 000..73b4c5b
> --- /dev/null
> +++ b/lib/lp/registry/interfaces/socialaccount.py
> @@ -0,0 +1,90 @@
> +# Copyright 2023 Canonical Ltd.  This software is licensed under the
> +# GNU Affero General Public License version 3 (see the file LICENSE).
> +
> +"""SocialAccount interfaces."""
> +
> +__all__ = ["ISocialAccount", "ISocialAccountSet", "PlatformType"]
> +
> +from lazr.enum import DBEnumeratedType, DBItem
> +from lazr.restful.declarations import exported, exported_as_webservice_entry
> +from lazr.restful.fields import Reference
> +from zope.interface import Interface
> +from zope.schema import Choice, Dict, Int, TextLine
> +
> +from lp import _
> +from lp.registry.interfaces.role import IHasOwner
> +
> +
> +class PlatformType(DBEnumeratedType):

This is a WIP: we need to define here the platformTypes and the related 
descriptions.

> +"""Platform Type
> +
> +When a social account is added it is referring
> +to a given platform type.
> +"""
> +
> +MATRIX = DBItem(
> +1,
> +"""
> +Matrix platform
> +
> +To define matrix
> +""",
> +)
> +
> +JABBER = DBItem(
> +2,
> +"""
> +Jabber platform
> +
> +To define jabber
> +""",
> +)
> +
> +
> +@exported_as_webservice_entry(as_of="beta")
> +class ISocialAccount(IHasOwner):
> +"""Jabber specific user ID"""
> +
> +id = Int(title=_("Database ID"), required=True, readonly=True)
> +# schema=Interface will be overridden in person.py because of circular
> +# dependencies.
> +person = exported(
> +Reference(
> +title=_("Owner"), required=True, schema=Interface, readonly=True
> +)
> +)
> +
> +platform = exported(
> +Choice(
> +title=_("Platform type"),
> +required=True,
> +vocabulary=PlatformType,
> +default=PlatformType.MATRIX,
> +)
> +)
> +
> +identity = exported(
> +Dict(
> +title=_("SocialAccount identity"),
> +key_type=TextLine(),
> +required=True,
> +readonly=False,
> +description=_(
> +"A dictionary mapping attributes for the social media 
> account "
> +"(JSON format specific per social media platform). "
> +),
> +)
> +)
> +
> +def destroySelf():
> +"""Delete this SocialAccount from the database."""
> +
> +
> +class ISocialAccountSet(Interface):
> +"""The set of SocialAccounts."""
> +
> +def new(self, person, platform, identity):
> +"""Create a new SocialAccount pointing to the given Person."""
> +
> +def getByPerson(person):
> +"""Return all SocialAccounts for the given person."""


-- 
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/457527
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:social-account-interface-and-implementation into 
launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:social-account-interface-and-implementation into launchpad:master

2023-12-14 Thread Simone Pelosi
The proposal to merge 
~pelpsi/launchpad:social-account-interface-and-implementation into 
launchpad:master has been updated.

Commit message changed to:

SocialAccount interface and implementation

SocialAccount interface to reflect DB table SocialAccount:
each row of this new table is storing SocialAccount infomation
associated to one person. One person could have more than one
SocialAccount. This change is required since we are implementing
Matrix.

Reference: 
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/457221

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/457527
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:social-account-interface-and-implementation into 
launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:social-account-interface-and-implementation into launchpad:master

2023-12-14 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:social-account-interface-and-implementation into 
launchpad:master.

Commit message:
SocialAccount interface and implementation

SocialAccount interface to reflect DB table SocialAccount:
each row of this new table is storing SocialAccount infomation 
associated to one person. One person could have more than one
SocialAccount. This change is required since we are implementing
Matrix.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/457527
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:social-account-interface-and-implementation into 
launchpad:master.
diff --git a/lib/lp/registry/configure.zcml b/lib/lp/registry/configure.zcml
index 3cf36a8..e362c03 100644
--- a/lib/lp/registry/configure.zcml
+++ b/lib/lp/registry/configure.zcml
@@ -650,6 +650,17 @@
 interface="lp.registry.interfaces.jabber.IJabberIDSet"/>
 
 
+
+
+
+
+
+
 
diff --git a/lib/lp/registry/doc/socialaccount.rst b/lib/lp/registry/doc/socialaccount.rst
new file mode 100644
index 000..84542be
--- /dev/null
+++ b/lib/lp/registry/doc/socialaccount.rst
@@ -0,0 +1,31 @@
+Social Accounts
+==
+
+Social Accounts are associated with a person and must be created through the
+ISocialAccountSet utility.
+
+>>> from lp.registry.interfaces.person import IPersonSet
+>>> from lp.registry.interfaces.role import IHasOwner
+>>> from lp.registry.interfaces.socialaccount import (
+... ISocialAccount,
+... ISocialAccountSet,
+... PlatformType,
+... )
+
+The new() method of ISocialAccountSet takes the person who will be associated
+with the Social Account, a platform type and an identity dictionary.
+
+>>> salgado = getUtility(IPersonSet).getByName("salgado")
+>>> identity = {}
+>>> identity["matrix_id"] = "abc"
+>>> social_account = getUtility(ISocialAccountSet).new(
+... salgado, PlatformType.MATRIX, identity
+... )
+
+The returned SocialAccount object provides both ISocialAccount and IHasOwner.
+
+>>> from lp.testing import verifyObject
+>>> verifyObject(ISocialAccount, social_account)
+True
+>>> verifyObject(IHasOwner, social_account)
+True
diff --git a/lib/lp/registry/interfaces/person.py b/lib/lp/registry/interfaces/person.py
index 3aeae4c..bdb5ca6 100644
--- a/lib/lp/registry/interfaces/person.py
+++ b/lib/lp/registry/interfaces/person.py
@@ -121,6 +121,7 @@ from lp.registry.interfaces.location import (
 from lp.registry.interfaces.mailinglistsubscription import (
 MailingListAutoSubscribePolicy,
 )
+from lp.registry.interfaces.socialaccount import ISocialAccount
 from lp.registry.interfaces.ssh import ISSHKey
 from lp.registry.interfaces.teammembership import (
 ITeamMembership,
@@ -1030,6 +1031,15 @@ class IPersonViewRestricted(
 ),
 exported_as="jabber_ids",
 )
+socialaccounts = exported(
+CollectionField(
+title=_("List of Social Accounts of this Person."),
+readonly=True,
+required=False,
+value_type=Reference(schema=ISocialAccount),
+),
+exported_as="social_accounts",
+)
 team_memberships = exported(
 CollectionField(
 title=_(
@@ -3241,3 +3251,4 @@ patch_reference_property(IIrcID, "person", IPerson)
 patch_reference_property(IJabberID, "person", IPerson)
 patch_reference_property(IWikiName, "person", IPerson)
 patch_reference_property(IEmailAddress, "person", IPerson)
+patch_reference_property(ISocialAccount, "person", IPerson)
diff --git a/lib/lp/registry/interfaces/socialaccount.py b/lib/lp/registry/interfaces/socialaccount.py
new file mode 100644
index 000..f23a457
--- /dev/null
+++ b/lib/lp/registry/interfaces/socialaccount.py
@@ -0,0 +1,90 @@
+# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Jabber interfaces."""
+
+__all__ = ["ISocialAccount", "ISocialAccountSet", "PlatformType"]
+
+from lazr.enum import DBEnumeratedType, DBItem
+from lazr.restful.declarations import exported, exported_as_webservice_entry
+from lazr.restful.fields import Reference
+from zope.interface import Interface
+from zope.schema import Choice, Dict, Int, TextLine
+
+from lp import _
+from lp.registry.interfaces.role import IHasOwner
+
+
+class PlatformType(DBEnumeratedType):
+"""Platform Type
+
+When a social account is added it is referring
+to a given platform type.
+

[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:copy-distroseries-translations-fix into launchpad:master

2023-10-30 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:copy-distroseries-translations-fix into launchpad:master.

Commit message:
Addded translations_distroseries_copy role to launchpad-scripts charm

This role is required to run copy-distroseries-translations.py script
during the translations opening process.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/454810
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:copy-distroseries-translations-fix into launchpad:master.
diff --git a/charm/launchpad-scripts/layer.yaml b/charm/launchpad-scripts/layer.yaml
index c0312b0..db64ae8 100644
--- a/charm/launchpad-scripts/layer.yaml
+++ b/charm/launchpad-scripts/layer.yaml
@@ -57,6 +57,7 @@ options:
   - statistician
   - targetnamecacheupdater
   - teammembership
+  - translations_distroseries_copy
   - translations_import_queue_gardener
   - update-pkg-cache
   - upload_package_translations_job
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~pelpsi/launchpad:ftpmaster-publisher-configuration into launchpad:master

2023-10-17 Thread Simone Pelosi



Diff comments:

> diff --git a/charm/launchpad-ftpmaster-publisher/config.yaml 
> b/charm/launchpad-ftpmaster-publisher/config.yaml
> index d871574..b33716b 100644
> --- a/charm/launchpad-ftpmaster-publisher/config.yaml
> +++ b/charm/launchpad-ftpmaster-publisher/config.yaml
> @@ -7,6 +7,18 @@ options:
>  type: string
>  description: Domain name for the published Ubuntu archive.
>  default: "archive.ubuntu.test"
> +  ftp_auth_users:

Here I differentiated auth_users for the [ftp] entry and [partner]. I don't 
know if it makes sense but they may have different configurations. Same for 
hosts_allow.

> +type: string
> +description: Authenticated users for rsync ubuntu
> +default: ""
> +  ftp_secrets:
> +type: string
> +description: Path for rsync secrets
> +default: ""
> +  partner_auth_users:
> +type: string
> +description: Authenticated users for rsync ubuntu-partner
> +default: ""
>signing_client_public_key:
>  type: string
>  description: Public key for encrypting communication between client and 
> signing service. 


-- 
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/453838
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:ftpmaster-publisher-configuration into launchpad:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:ftpmaster-publisher-configuration into launchpad:master

2023-10-17 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:ftpmaster-publisher-configuration into launchpad:master.

Commit message:
Added rsync configuration to ftpmaster publisher

According to the legacy deployment of the publisher
we added a configuration file to configure correctly rsync

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/453838
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:ftpmaster-publisher-configuration into launchpad:master.
diff --git a/charm/launchpad-ftpmaster-publisher/config.yaml b/charm/launchpad-ftpmaster-publisher/config.yaml
index d871574..b33716b 100644
--- a/charm/launchpad-ftpmaster-publisher/config.yaml
+++ b/charm/launchpad-ftpmaster-publisher/config.yaml
@@ -7,6 +7,18 @@ options:
 type: string
 description: Domain name for the published Ubuntu archive.
 default: "archive.ubuntu.test"
+  ftp_auth_users:
+type: string
+description: Authenticated users for rsync ubuntu
+default: ""
+  ftp_secrets:
+type: string
+description: Path for rsync secrets
+default: ""
+  partner_auth_users:
+type: string
+description: Authenticated users for rsync ubuntu-partner
+default: ""
   signing_client_public_key:
 type: string
 description: Public key for encrypting communication between client and signing service. 
@@ -23,3 +35,11 @@ options:
 type: string
 description: Webmaster contact address.
 default: "webmas...@launchpad.test"
+  ubuntu_dists_hosts_allow:
+type: string
+description: IP addresses permitted to connect to ubuntu/dists.
+default: ""
+  ubuntu_germinate_hosts_allow:
+type: string
+description: IP addresses permitted to connect to ubuntu-germinate.
+default: ""
\ No newline at end of file
diff --git a/charm/launchpad-ftpmaster-publisher/reactive/launchpad-ftpmaster-publisher.py b/charm/launchpad-ftpmaster-publisher/reactive/launchpad-ftpmaster-publisher.py
index 0342c89..eb1a447 100644
--- a/charm/launchpad-ftpmaster-publisher/reactive/launchpad-ftpmaster-publisher.py
+++ b/charm/launchpad-ftpmaster-publisher/reactive/launchpad-ftpmaster-publisher.py
@@ -57,6 +57,12 @@ def configure():
 "launchpad-ftpmaster-publisher-secrets-lazr.conf",
 secret=True,
 )
+templating.render(
+"publisher.conf.j2",
+"/etc/rsync-juju.d/publisher.conf",
+config,
+perms=0o644,
+)
 configure_email(config, "launchpad-ftpmaster-publisher")
 configure_logrotate(config)
 configure_cron(config, "crontab.j2")
diff --git a/charm/launchpad-ftpmaster-publisher/templates/publisher.conf.j2 b/charm/launchpad-ftpmaster-publisher/templates/publisher.conf.j2
new file mode 100644
index 000..e5d5f9a
--- /dev/null
+++ b/charm/launchpad-ftpmaster-publisher/templates/publisher.conf.j2
@@ -0,0 +1,32 @@
+max connections = 25
+
+[ftp]
+  path = {{ archives_dir }}/ubuntu-archive/ubuntu
+  comment = Ubuntu Archive
+  list = false
+  read only = true
+  auth users = {{ ftp_auth_users }}
+  secrets file = {{ ftp_secrets }}
+
+[partner]
+  path = {{ archives_dir }}/ubuntu-archive/ubuntu-partner/
+  comment = Partner
+  list = false
+  read only = true
+  auth users = {{ partner_auth_users }}
+  secrets file = {{ ftp_secrets }}
+
+[ubuntu-dists]
+  path = {{ archives_dir }}/ubuntu-archive/ubuntu/dists
+  comment = Ubuntu Archive Dists
+  list = false
+  read only = true
+  hosts allow = {{ ubuntu_dists_hosts_allow }}
+
+[ubuntu-germinate]
+  path = {{ archives_dir }}/ubuntu-archive/ubuntu-germinate
+  comment = Ubuntu Archive Germinate output
+  list = false
+  read only = true
+  hosts allow = {{ ubuntu_germinate_hosts_allow }}
+
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:ftpmaster-publisher-403-error into launchpad:master

2023-10-17 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:ftpmaster-publisher-403-error into launchpad:master.

Commit message:
Fixed wrong archive dir


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/453808
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:ftpmaster-publisher-403-error into launchpad:master.
diff --git a/charm/launchpad-ftpmaster-publisher/templates/vhost.conf.j2 b/charm/launchpad-ftpmaster-publisher/templates/vhost.conf.j2
index 5206c4a..169ff83 100644
--- a/charm/launchpad-ftpmaster-publisher/templates/vhost.conf.j2
+++ b/charm/launchpad-ftpmaster-publisher/templates/vhost.conf.j2
@@ -1,13 +1,13 @@
 
 ServerName {{ domain_ftpmaster }}
 
-DocumentRoot {{ archives_dir }}/
+DocumentRoot {{ archives_dir }}/ubuntu-archive/
 
 CustomLog /var/log/apache2/{{ domain_ftpmaster }}-access.log combined
 ErrorLog /var/log/apache2/{{ domain_ftpmaster }}-error.log
 
 {% for distribution in ("ubuntu", "ubuntu-partner") %}
-
+
 IndexOptions NameWidth=* +SuppressDescription
 Options +Indexes +FollowSymLinks
 IndexIgnore favicon.ico
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/txpkgupload:build-dropin-cache-make-compile into txpkgupload:master

2023-09-05 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/txpkgupload:build-dropin-cache-make-compile into txpkgupload:master.

Commit message:
Added plugincache.py file to build dropin.cache

Make file will call `TWISTD_BUILD_CACHE` once the `plugincache.py`
file is compiled as console_script by setup.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/txpkgupload/+git/txpkgupload/+merge/450702
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/txpkgupload:build-dropin-cache-make-compile into txpkgupload:master.
diff --git a/Makefile b/Makefile
index b849c49..3b3935d 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,7 @@ VIRTUALENV += --extra-search-dir=$(DEPENDENCY_DIR)/
 PIP := $(PIP_ENV) $(ENV)/bin/pip
 
 TWISTD = $(ENV)/bin/twistd
+TWISTD_BUILD_CACHE = $(ENV)/bin/build-twisted-plugin-cache
 
 VERSION_INFO = version-info.py
 
@@ -47,6 +48,7 @@ bootstrap: $(DEPENDENCY_DIR)
 
 compile:
 	$(MAKE) $(ENV)
+	$(TWISTD_BUILD_CACHE)
 	[ ! -d .git ] || $(MAKE) $(VERSION_INFO)
 
 
diff --git a/setup.py b/setup.py
index fc284de..6f3ae16 100755
--- a/setup.py
+++ b/setup.py
@@ -81,6 +81,11 @@ setup(
 test=['fixtures',
   'testtools'],
 ),
+entry_points={
+'console_scripts': [
+'build-twisted-plugin-cache = twisted.plugins.plugincache:main',
+]
+},
 # This does not play nicely with buildout because it downloads but does
 # not cache the package.
 # setup_requires=['eggtestinfo', 'setuptools_bzr'],
diff --git a/src/twisted/plugins/plugincache.py b/src/twisted/plugins/plugincache.py
new file mode 100644
index 000..f71dcba
--- /dev/null
+++ b/src/twisted/plugins/plugincache.py
@@ -0,0 +1,17 @@
+# Copyright 2023 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Build dropin.cache for all installed Twisted plugins.
+
+This would be built on the fly if we didn't do it here, but we want to make
+sure to build it in a predictable environment.  In particular, if a plugin's
+cache is first built as a result of being run via ampoule, then ampoule will
+fail if any part of the process of importing the plugin installs a default
+reactor.
+"""
+
+from twisted.plugin import IPlugin, getPlugins
+
+
+def main():
+list(getPlugins(IPlugin))
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:typeerror-unmarshall-non-string-objects into launchpad:master

2023-08-31 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:typeerror-unmarshall-non-string-objects into launchpad:master.

Commit message:
Unmarshall calls `obfuscated_structure` instead of `obfuscated_email`

Calling `obfuscated_structure` gives more input control avoiding
TypeError exception caused by passing to `obfuscated_email` a non-string
value.

LP: #2033382



Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #2033382 in Launchpad itself: "TypeError when trying to access 
https://api.launchpad.net/devel/~ubuntu-core-service/+snap/core20/;
  https://bugs.launchpad.net/launchpad/+bug/2033382

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/450364
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:typeerror-unmarshall-non-string-objects into launchpad:master.
diff --git a/lib/lp/app/webservice/marshallers.py b/lib/lp/app/webservice/marshallers.py
index e7601d2..a1275b8 100644
--- a/lib/lp/app/webservice/marshallers.py
+++ b/lib/lp/app/webservice/marshallers.py
@@ -17,7 +17,7 @@ from zope.component import getMultiAdapter, getUtility
 from zope.interface.interfaces import ComponentLookupError
 from zope.schema.interfaces import IField, RequiredMissing
 
-from lp.services.utils import obfuscate_email
+from lp.services.utils import obfuscate_structure
 from lp.services.webapp.interfaces import ILaunchBag
 
 
@@ -31,7 +31,7 @@ class TextFieldMarshaller(LazrTextFieldMarshaller):
 """
 
 if value is not None and getUtility(ILaunchBag).user is None:
-return obfuscate_email(value)
+return obfuscate_structure(value)
 return value
 
 
diff --git a/lib/lp/app/webservice/tests/test_marshallers.py b/lib/lp/app/webservice/tests/test_marshallers.py
index 006a1bd..765f2c8 100644
--- a/lib/lp/app/webservice/tests/test_marshallers.py
+++ b/lib/lp/app/webservice/tests/test_marshallers.py
@@ -44,6 +44,16 @@ class TestTextFieldMarshaller(TestCaseWithFactory):
 result = marshaller.unmarshall(None, "f...@example.com")
 self.assertEqual("f...@example.com", result)
 
+def test_unmarshall_obfuscated_int_value(self):
+marshaller = TextFieldMarshaller(None, WebServiceTestRequest())
+result = marshaller.unmarshall(None, 1)
+self.assertEqual(1, result)
+
+def test_unmarshall_obfuscated_dict_value(self):
+marshaller = TextFieldMarshaller(None, WebServiceTestRequest())
+result = marshaller.unmarshall(None, {"foo": (["a...@example.com"],)})
+self.assertEqual({"foo": [[""]]}, result)
+
 
 class TestWebServiceObfuscation(TestCaseWithFactory):
 """Integration test for obfuscation marshaller.
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:ftpmaster-bug-fixing into launchpad:master

2023-08-11 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/launchpad:ftpmaster-bug-fixing into 
launchpad:master.

Commit message:
Created required folder

srv/launchpad/ubuntu-queue/{incoming,accepted,rejected,failed} folders created 
in order to
fix a `Permission Denied` error in the ftpmaster uploader charm.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/448990
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:ftpmaster-bug-fixing into launchpad:master.
diff --git a/charm/launchpad-ftpmaster-uploader/reactive/launchpad-ftpmaster-uploader.py b/charm/launchpad-ftpmaster-uploader/reactive/launchpad-ftpmaster-uploader.py
index 641cc00..e1edf68 100644
--- a/charm/launchpad-ftpmaster-uploader/reactive/launchpad-ftpmaster-uploader.py
+++ b/charm/launchpad-ftpmaster-uploader/reactive/launchpad-ftpmaster-uploader.py
@@ -38,6 +38,16 @@ def configure():
 config = get_service_config()
 config["ubuntu_queue_dir"] = os.path.join(base.base_dir(), "ubuntu-queue")
 host.mkdir(config["ubuntu_queue_dir"], perms=0o755)
+host.mkdir(
+os.path.join(config["ubuntu_queue_dir"], "incoming"), perms=0o755
+)
+host.mkdir(
+os.path.join(config["ubuntu_queue_dir"], "accepted"), perms=0o755
+)
+host.mkdir(
+os.path.join(config["ubuntu_queue_dir"], "rejected"), perms=0o755
+)
+host.mkdir(os.path.join(config["ubuntu_queue_dir"], "failed"), perms=0o755)
 
 configure_lazr(
 config,
@@ -53,7 +63,9 @@ def configure():
 @when("service.configured", "upload-queue-processor.available")
 @when_not("service.txpkgupload-configured")
 def configure_txpkgupload():
-fsroot = os.path.join(base.base_dir(), "incoming")
+fsroot = os.path.join(
+os.path.join(base.base_dir(), "ubuntu-queue"), "incoming"
+)
 txpkgupload = endpoint_from_flag("upload-queue-processor.available")
 txpkgupload.set_config(
 fsroot=fsroot,
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:team-subscription-bug into launchpad:master

2023-08-08 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/launchpad:team-subscription-bug into 
launchpad:master.

Commit message:
Flushing db before txn.commit() and txn.abort()


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/448706
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:team-subscription-bug into launchpad:master.
diff --git a/lib/lp/services/webapp/publication.py b/lib/lp/services/webapp/publication.py
index 1557a46..fb51750 100644
--- a/lib/lp/services/webapp/publication.py
+++ b/lib/lp/services/webapp/publication.py
@@ -50,6 +50,7 @@ from lp.services.database.interfaces import (
 IStoreSelector,
 )
 from lp.services.database.policy import LaunchpadDatabasePolicy
+from lp.services.database.sqlbase import flush_database_updates
 from lp.services.features.flags import NullFeatureController
 from lp.services.oauth.interfaces import IOAuthSignedRequest
 from lp.services.statsd.interfaces.statsd_client import IStatsdClient
@@ -504,6 +505,7 @@ class LaunchpadBrowserPublication(
 
 # Abort the transaction on a read-only request.
 # NOTHING AFTER THIS SHOULD CAUSE A RETRY.
+flush_database_updates()
 if request.method in ["GET", "HEAD"]:
 self.finishReadOnlyRequest(txn)
 elif txn.isDoomed():
diff --git a/lib/lp/services/webapp/tests/test_publication.py b/lib/lp/services/webapp/tests/test_publication.py
index a9c246a..cdc1570 100644
--- a/lib/lp/services/webapp/tests/test_publication.py
+++ b/lib/lp/services/webapp/tests/test_publication.py
@@ -14,6 +14,7 @@ from zope.component import getUtility
 from zope.interface import directlyProvides
 from zope.publisher.interfaces import NotFound, Retry
 from zope.publisher.publish import publish
+from zope.security.interfaces import Unauthorized
 from zope.security.management import thread_local as zope_security_thread_local
 
 import lp.services.webapp.adapter as dbadapter
@@ -38,7 +39,13 @@ from lp.services.webapp.servers import (
 WebServicePublication,
 )
 from lp.services.webapp.vhosts import allvhosts
-from lp.testing import ANONYMOUS, TestCase, TestCaseWithFactory, login
+from lp.testing import (
+ANONYMOUS,
+BrowserTestCase,
+TestCase,
+TestCaseWithFactory,
+login,
+)
 from lp.testing.fakemethod import FakeMethod
 from lp.testing.layers import DatabaseFunctionalLayer
 
@@ -454,3 +461,26 @@ class TestPublisherStats(StatsMixin, TestCaseWithFactory):
 browser = self.getUserBrowser()
 # This shouldn't raise ValueError
 self.assertRaises(NotFound, browser.open, redirect_url)
+
+
+class TestSubscriptions(BrowserTestCase, TestCaseWithFactory):
+layer = DatabaseFunctionalLayer
+
+def test_subscriptions(self):
+owner = self.factory.makePerson()
+canonicals = []
+canonicals.append(self.factory.makePerson())
+
+self.factory.makeTeam(name="canonical", members=canonicals)
+ppa = self.factory.makeArchive(owner=owner, private=True)
+
+self.assertRaises(
+Unauthorized, self.getViewBrowser, ppa, user=canonicals[0]
+)
+
+browser = self.getViewBrowser(
+ppa, view_name="+subscriptions", user=owner
+)
+browser.getControl(name="field.subscriber").value = "canonical"
+browser.getControl("Add").click()
+browser = self.getViewBrowser(ppa, user=canonicals[0])
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:merge-proposal-url-fix into launchpad:master

2023-08-07 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/launchpad:merge-proposal-url-fix 
into launchpad:master.

Commit message:
mp.address replaced with canonical_url(mp, rootsite="code")


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/448614
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:merge-proposal-url-fix into launchpad:master.
diff --git a/lib/lp/code/xmlrpc/git.py b/lib/lp/code/xmlrpc/git.py
index 6e39e8c..c2ad0ce 100644
--- a/lib/lp/code/xmlrpc/git.py
+++ b/lib/lp/code/xmlrpc/git.py
@@ -731,7 +731,10 @@ class GitAPI(LaunchpadXMLRPCView):
 return (
 "Updated existing merge proposal "
 "for %s on Launchpad:\n  %s"
-% (quote(branch), merge_proposal.address)
+% (
+quote(branch),
+canonical_url(merge_proposal, rootsite="code"),
+)
 )
 else:
 base_url = canonical_url(repository, rootsite="code")
diff --git a/lib/lp/code/xmlrpc/tests/test_git.py b/lib/lp/code/xmlrpc/tests/test_git.py
index 4764319..f03072a 100644
--- a/lib/lp/code/xmlrpc/tests/test_git.py
+++ b/lib/lp/code/xmlrpc/tests/test_git.py
@@ -678,7 +678,7 @@ class TestGitAPIMixin:
 expected_mp_url = (
 "Updated existing merge proposal "
 "for %s on Launchpad:\n  %s"
-% (quote(pushed_branch), mp.address)
+% (quote(pushed_branch), canonical_url(mp, rootsite="code"))
 )
 
 result = self.git_api.getMergeProposalInfo(
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:differentiate-git-push-message-if-mp-exists into launchpad:master

2023-08-07 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:differentiate-git-push-message-if-mp-exists into 
launchpad:master.

Commit message:
Differentiate git push message if the MP exists

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/448597
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:differentiate-git-push-message-if-mp-exists into 
launchpad:master.
diff --git a/lib/lp/code/interfaces/branchmergeproposal.py b/lib/lp/code/interfaces/branchmergeproposal.py
index e65eef6..1b3c916 100644
--- a/lib/lp/code/interfaces/branchmergeproposal.py
+++ b/lib/lp/code/interfaces/branchmergeproposal.py
@@ -971,6 +971,13 @@ class IBranchMergeProposalGetter(Interface):
 def get(id):
 """Return the BranchMergeProposal with specified id."""
 
+def activeProposalsForBranches(source, target=None):
+"""Return BranchMergeProposals having a given source and target.
+
+:param source: source branch
+:param target: target branch
+"""
+
 def getProposalsForContext(context, status=None, visible_by_user=None):
 """Return BranchMergeProposals associated with the context.
 
diff --git a/lib/lp/code/interfaces/gitapi.py b/lib/lp/code/interfaces/gitapi.py
index 5495944..f6bb38b 100644
--- a/lib/lp/code/interfaces/gitapi.py
+++ b/lib/lp/code/interfaces/gitapi.py
@@ -95,6 +95,22 @@ class IGitAPI(Interface):
 or an `Unauthorized` fault for unauthorized push attempts.
 """
 
+def getMergeProposalInfo(translated_path, branch, auth_params):
+"""Return the info (string) for a merge proposal.
+
+When a `branch` that is not the default branch in a repository
+is pushed, the URL where the merge proposal for that branch can
+be opened will be generated and returned if the merge proposal
+doesn't exist, otherwise the link of the existing merge proposal
+will be returned.
+
+:returns: The URL to register a merge proposal or the link of
+an existing merge proposal for the branch in the
+specified repository. A `GitRepositoryNotFound` fault is returned
+if no repository can be found for 'translated_path',
+or an `Unauthorized` fault for unauthorized push attempts.
+"""
+
 def confirmRepoCreation(repository_id):
 """Confirm that repository creation.
 
diff --git a/lib/lp/code/interfaces/gitrepository.py b/lib/lp/code/interfaces/gitrepository.py
index 7f6053f..4f57972 100644
--- a/lib/lp/code/interfaces/gitrepository.py
+++ b/lib/lp/code/interfaces/gitrepository.py
@@ -787,6 +787,21 @@ class IGitRepositoryView(IHasRecipes):
 diffs updated.
 """
 
+def makeFrozenRef(path, commit_sha1):
+"""A frozen Git reference.
+
+This is like a GitRef, but is frozen at a particular commit, even if
+the real reference has moved on or has been deleted.
+It isn't necessarily backed by a real database object,
+and will retrieve columns from the database when required.
+Use this when you have a repository/path/commit_sha1 that you want
+to pass around as a single object,
+but don't necessarily know that the ref still exists.
+
+:param path: the repository reference path.
+:param commit_sha1: the commit sha1 for that repository reference path.
+"""
+
 def markRecipesStale(paths):
 """Mark recipes associated with this repository as stale.
 
diff --git a/lib/lp/code/model/branchmergeproposal.py b/lib/lp/code/model/branchmergeproposal.py
index 924658c..17ecffc 100644
--- a/lib/lp/code/model/branchmergeproposal.py
+++ b/lib/lp/code/model/branchmergeproposal.py
@@ -1805,7 +1805,7 @@ class BranchMergeProposalGetter:
 return result
 
 @staticmethod
-def activeProposalsForBranches(source, target):
+def activeProposalsForBranches(source, target=None):
 clauses = [Not(BranchMergeProposal.queue_status.is_in(FINAL_STATES))]
 if IGitRef.providedBy(source):
 clauses.extend(
@@ -1813,11 +1813,18 @@ class BranchMergeProposalGetter:
 BranchMergeProposal.source_git_repository
 == source.repository,
 BranchMergeProposal.source_git_path == source.path,
-BranchMergeProposal.target_git_repository
-== target.repository,
-BranchMergeProposal.target_git_path == target.path,
 ]
 )
+
+if target:
+clauses.extend(
+[
+BranchMergeProposal.target_g

[Launchpad-reviewers] [Merge] ~pelpsi/turnip:charm-build-fix into turnip:master

2023-08-03 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/turnip:charm-build-fix into 
turnip:master.

Commit message:
Fixed revision numbers



Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/turnip/+git/turnip/+merge/448405
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/turnip:charm-build-fix into turnip:master.
diff --git a/charm/dependencies.txt b/charm/dependencies.txt
index 7d83558..c5b2664 100644
--- a/charm/dependencies.txt
+++ b/charm/dependencies.txt
@@ -1,15 +1,15 @@
 interface			@
-interface/rabbitmq		git+https://github.com/openstack/charm-interface-rabbitmq;revno=571f486
-interface/http			git+https://github.com/juju-solutions/interface-http;revno=4a232c69
-interface/mount			git+https://github.com/juju-solutions/interface-mount;revno=d5a2526f
-interface/nrpe-external-master	git+https://github.com/canonical-ols/nrpe-external-master-interface;revno=20b2b9fb
+interface/rabbitmq		git+https://github.com/openstack/charm-interface-rabbitmq;revno=383121fc584d2d3bf9d233eba0d3708398a4c468
+interface/http			git+https://github.com/juju-solutions/interface-http;revno=632131b1f122daf6fb601fd4c9f1e4dbb1a92e09
+interface/mount			git+https://github.com/juju-solutions/interface-mount;revno=d5a2526fec9c3e8581f18b56e84a86871583e080
+interface/nrpe-external-master	git+https://github.com/canonical-ols/nrpe-external-master-interface;revno=3a195bf592c6b45a58fce0d398ba6921dd0bae3b
 
 layer@
-layer/apt			git+https://git.launchpad.net/layer-apt;revno=cf78622e
-layer/basic			git+https://github.com/juju-solutions/layer-basic;revno=baf58223
-layer/options			git+https://github.com/juju-solutions/layer-options;revno=fcdcea4e
-layer/status			git+https://github.com/juju-solutions/layer-status;revno=02658f0f
+layer/apt			git+https://git.launchpad.net/layer-apt;revno=76bddfb640ab8767fc7e4a4b73a4a4e781948f34
+layer/basic			git+https://github.com/juju-solutions/layer-basic;revno=e3affe74ff0c33e2fbfc560fcd1d873726c40233
+layer/options			git+https://github.com/juju-solutions/layer-options;revno=fcdcea4e5de3e1556c24e6704607862d0ba00a56
+layer/status			git+https://github.com/juju-solutions/layer-status;revno=a7d7b6423db37a47611310039e6ed1929c0a2eab
 layer/turnip-base		../../../layer/turnip-base;method=link
 layer/turnip-storage		../../../layer/turnip-storage;method=link
 
-charm-wheels			git+https://git.launchpad.net/~ubuntuone-hackers/ols-charm-deps/+git/wheels
+charm-wheels			git+https://git.launchpad.net/~ubuntuone-hackers/ols-charm-deps/+git/wheels;revno=7bcd79fa4fca485eaf15ee9e2ee16f3ab902678d
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:cannot-turn-lp-subteam-to-private into launchpad:master

2023-08-03 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:cannot-turn-lp-subteam-to-private into launchpad:master.

Commit message:
Added a status check if src_tab=="teammembership"

teammembership should be considered only if has a status different from DEACTIV>

LP: #2029487


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #2029487 in Launchpad itself: "Cannot turn LP team to Private"
  https://bugs.launchpad.net/launchpad/+bug/2029487

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/448383
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:cannot-turn-lp-subteam-to-private into launchpad:master.
diff --git a/lib/lp/registry/model/person.py b/lib/lp/registry/model/person.py
index 3a7d1a5..96691ee 100644
--- a/lib/lp/registry/model/person.py
+++ b/lib/lp/registry/model/person.py
@@ -2777,11 +2777,20 @@ class Person(
 for src_tab, src_col, ref_tab, ref_col, updact, delact in references:
 if (src_tab, src_col) in skip:
 continue
-ref_query.append(
+query = (
 "SELECT '%(table)s' AS table FROM %(table)s "
 "WHERE %(col)s = %(person_id)d"
 % {"col": src_col, "table": src_tab, "person_id": self.id}
 )
+if src_tab == "teammembership":
+query += (
+" AND status != %(deactivated)d AND status != %(expired)d"
+% {
+"deactivated": TeamMembershipStatus.DEACTIVATED.value,
+"expired": TeamMembershipStatus.EXPIRED.value,
+}
+)
+ref_query.append(query)
 if ref_query:
 cur.execute(" UNION ".join(ref_query))
 for src_tab in cur.fetchall():
diff --git a/lib/lp/registry/tests/test_person.py b/lib/lp/registry/tests/test_person.py
index 3646ff7..131ceff 100644
--- a/lib/lp/registry/tests/test_person.py
+++ b/lib/lp/registry/tests/test_person.py
@@ -38,6 +38,7 @@ from lp.registry.interfaces.karma import IKarmaCacheManager
 from lp.registry.interfaces.person import ImmutableVisibilityError, IPersonSet
 from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.registry.interfaces.product import IProductSet
+from lp.registry.interfaces.teammembership import ITeamMembershipSet
 from lp.registry.model.karma import KarmaCategory, KarmaTotalCache
 from lp.registry.model.person import Person, get_recipients
 from lp.services.database.interfaces import IStore
@@ -1088,6 +1089,36 @@ class TestPersonStates(TestCaseWithFactory):
 else:
 raise AssertionError("Expected exception.")
 
+def test_visibility_validator_subteam_public_to_private_view(self):
+team_owner = self.factory.makePerson()
+new_team = self.factory.makeTeam(
+owner=team_owner, visibility=PersonVisibility.PUBLIC
+)
+super_team = self.factory.makeTeam(
+owner=team_owner,
+visibility=PersonVisibility.PUBLIC,
+members=[new_team],
+)
+membershipset = getUtility(ITeamMembershipSet)
+membershipset.deactivateActiveMemberships(
+super_team, "gone", team_owner
+)
+view = create_initialized_view(
+new_team,
+"+edit",
+{
+"field.name": "newteam",
+"field.displayname": "New Team",
+"field.membership_policy": "RESTRICTED",
+"field.renewal_policy": "NONE",
+"field.visibility": "PRIVATE",
+"field.actions.save": "Save",
+},
+)
+self.assertEqual(len(view.errors), 0)
+self.assertEqual(len(view.request.notifications), 0)
+self.assertEqual(new_team.visibility, PersonVisibility.PRIVATE)
+
 def test_visibility_validator_team_private_to_public_view(self):
 # A PRIVATE team cannot convert to PUBLIC.
 self.otherteam.visibility = PersonVisibility.PRIVATE
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] ~pelpsi/turnip:turnip-charms-upgrade-to-focal into turnip:master

2023-07-26 Thread Simone Pelosi
Blocked by : 
https://code.launchpad.net/~pelpsi/ols-charm-deps/+git/wheels/+merge/447788

Once the above is merged, charm-wheels must be updated accordingly.
-- 
https://code.launchpad.net/~pelpsi/turnip/+git/turnip/+merge/447756
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/turnip:turnip-charms-upgrade-to-focal into turnip:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/turnip:turnip-charms-upgrade-to-focal into turnip:master

2023-07-26 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/turnip:turnip-charms-upgrade-to-focal into turnip:master.

Commit message:
Upgraded charms to focal

Updated layers to the latest commits
Updated charmcraft.yaml and metadata.yaml


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/turnip/+git/turnip/+merge/447756
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/turnip:turnip-charms-upgrade-to-focal into turnip:master.
diff --git a/charm/turnip-api/charmcraft.yaml b/charm/turnip-api/charmcraft.yaml
index b652a94..b329474 100644
--- a/charm/turnip-api/charmcraft.yaml
+++ b/charm/turnip-api/charmcraft.yaml
@@ -2,16 +2,16 @@ type: charm
 bases:
   - build-on:
 - name: ubuntu
-  channel: "18.04"
+  channel: "20.04"
   architectures: [amd64]
 run-on:
 - name: ubuntu
-  channel: "18.04"
+  channel: "20.04"
   architectures: [amd64]
 parts:
   charm-wheels:
-source: https://git.launchpad.net/~canonical-launchpad-branches/turnip/+git/dependencies
-source-commit: "030fe3e51edfe8e8c8b3590b52c4792b21631f01"
+source: https://git.launchpad.net/~pelpsi/turnip/+git/dependencies
+source-commit: "98a2ca73fabfbce1cd69bc04a95641bdae5817ea"
 source-submodules: []
 source-type: git
 plugin: dump
@@ -21,7 +21,7 @@ parts:
   - "-charm-wheels"
   interface-rabbitmq:
 source: https://github.com/openstack/charm-interface-rabbitmq
-source-commit: "571f4864c2f942d92991b3f413323a04c6f56d72"
+source-commit: "383121fc584d2d3bf9d233eba0d3708398a4c468"
 source-submodules: []
 source-type: git
 plugin: dump
@@ -33,7 +33,7 @@ parts:
   - "-layers"
   interface-http:
 source: https://github.com/juju-solutions/interface-http
-source-commit: "4a232c6998a0c7deac0c2362e7a9a4f1c776603b"
+source-commit: "632131b1f122daf6fb601fd4c9f1e4dbb1a92e09"
 source-submodules: []
 source-type: git
 plugin: dump
@@ -57,7 +57,7 @@ parts:
   - "-layers"
   interface-nrpe-external-master:
 source: https://github.com/canonical-ols/nrpe-external-master-interface
-source-commit: "20b2b9fb80613997cb99b8096040cbba72a0ef0c"
+source-commit: "3a195bf592c6b45a58fce0d398ba6921dd0bae3b"
 source-submodules: []
 source-type: git
 plugin: dump
@@ -69,7 +69,7 @@ parts:
   - "-layers"
   layer-apt:
 source: https://git.launchpad.net/layer-apt
-source-commit: "cf78622e68fe1ca97eb8993c5adc2616f9e110b9"
+source-commit: "76bddfb640ab8767fc7e4a4b73a4a4e781948f34"
 source-submodules: []
 source-type: git
 plugin: dump
@@ -81,7 +81,7 @@ parts:
   - "-layers"
   layer-basic:
 source: https://github.com/juju-solutions/layer-basic
-source-commit: "baf582236a7b946da4cd140fd6532a2e0c2774d5"
+source-commit: "e3affe74ff0c33e2fbfc560fcd1d873726c40233"
 source-submodules: []
 source-type: git
 plugin: dump
@@ -105,7 +105,7 @@ parts:
   - "-layers"
   layer-status:
 source: https://github.com/juju-solutions/layer-status
-source-commit: "02658f0f6b2d29316b79820b206cec532c0459c8"
+source-commit: "a7d7b6423db37a47611310039e6ed1929c0a2eab"
 source-submodules: []
 source-type: git
 plugin: dump
@@ -117,7 +117,7 @@ parts:
   - "-layers"
   launchpad-layers:
 source: https://git.launchpad.net/launchpad-layers
-source-commit: "466a8348106b0a14e4c1cf18fbafe13d1f927bad"
+source-commit: "300b0d9fd332c055395fe209512335cea03c7af3"
 source-submodules: []
 source-type: git
 plugin: dump
@@ -143,6 +143,7 @@ parts:
 source: .
 plugin: reactive
 build-snaps: [charm]
+build-packages: [python3-dev]
 build-environment:
   - CHARM_LAYERS_DIR: $CRAFT_STAGE/layers/layer
   - CHARM_INTERFACES_DIR: $CRAFT_STAGE/layers/interface
diff --git a/charm/turnip-api/metadata.yaml b/charm/turnip-api/metadata.yaml
index f506fcb..13c8578 100644
--- a/charm/turnip-api/metadata.yaml
+++ b/charm/turnip-api/metadata.yaml
@@ -10,6 +10,7 @@ tags:
   - network
   - web_server
 series:
+  - focal
   - bionic
   - xenial
 subordinate: false
diff --git a/charm/turnip-celery/charmcraft.yaml b/charm/turnip-celery/charmcraft.yaml
index 8afe6ef..42cb0ab 100644
--- a/charm/turnip-celery/charmcraft.yaml
+++ b/charm/turnip-celery/charmcraft.yaml
@@ -2,16 +2,16 @@ type: charm
 bases:
   - build-on:
 - name: ubuntu
-  channel: "18.04"
+  channel: "20.04"
   architectures: [amd64]
 run-on:
 - name: ubuntu
-  channel: "18.04"
+  channel: "20.04"
   architectures: [amd64]
 parts:
   charm-wheels:
-   

[Launchpad-reviewers] [Merge] ~pelpsi/turnip/+git/dependencies:turnip-upgrade-to-focal into ~canonical-launchpad-branches/turnip/+git/dependencies:master

2023-07-26 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/turnip/+git/dependencies:turnip-upgrade-to-focal into 
~canonical-launchpad-branches/turnip/+git/dependencies:master.

Commit message:
Updated wheels dependencies for focal

Added dependencies required by layer-base

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/turnip/+git/dependencies/+merge/447754
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/turnip/+git/dependencies:turnip-upgrade-to-focal into 
~canonical-launchpad-branches/turnip/+git/dependencies:master.
diff --git a/Cython-0.29.36.tar.gz b/Cython-0.29.36.tar.gz
new file mode 100644
index 000..d2ce057
Binary files /dev/null and b/Cython-0.29.36.tar.gz differ
diff --git a/Jinja2-3.1.2.tar.gz b/Jinja2-3.1.2.tar.gz
new file mode 100644
index 000..302517f
Binary files /dev/null and b/Jinja2-3.1.2.tar.gz differ
diff --git a/MarkupSafe-2.1.3.tar.gz b/MarkupSafe-2.1.3.tar.gz
new file mode 100644
index 000..4faf695
Binary files /dev/null and b/MarkupSafe-2.1.3.tar.gz differ
diff --git a/PyYAML-6.0.1.tar.gz b/PyYAML-6.0.1.tar.gz
new file mode 100644
index 000..8d032c8
Binary files /dev/null and b/PyYAML-6.0.1.tar.gz differ
diff --git a/charmhelpers-1.2.1.tar.gz b/charmhelpers-1.2.1.tar.gz
new file mode 100644
index 000..78f281b
Binary files /dev/null and b/charmhelpers-1.2.1.tar.gz differ
diff --git a/charms.reactive-1.5.2.tar.gz b/charms.reactive-1.5.2.tar.gz
new file mode 100644
index 000..433c84f
Binary files /dev/null and b/charms.reactive-1.5.2.tar.gz differ
diff --git a/flit_core-3.9.0.tar.gz b/flit_core-3.9.0.tar.gz
new file mode 100644
index 000..b34deac
Binary files /dev/null and b/flit_core-3.9.0.tar.gz differ
diff --git a/packaging-23.1.tar.gz b/packaging-23.1.tar.gz
new file mode 100644
index 000..80f2d80
Binary files /dev/null and b/packaging-23.1.tar.gz differ
diff --git a/pip-22.0.4.tar.gz b/pip-22.0.4.tar.gz
new file mode 100644
index 000..9dbc1c9
Binary files /dev/null and b/pip-22.0.4.tar.gz differ
diff --git a/pyaml-21.10.1.tar.gz b/pyaml-21.10.1.tar.gz
new file mode 100644
index 000..b19aad3
Binary files /dev/null and b/pyaml-21.10.1.tar.gz differ
diff --git a/setuptools-62.1.0.tar.gz b/setuptools-62.1.0.tar.gz
new file mode 100644
index 000..bcbf434
Binary files /dev/null and b/setuptools-62.1.0.tar.gz differ
diff --git a/setuptools_scm-6.4.2.tar.gz b/setuptools_scm-6.4.2.tar.gz
new file mode 100644
index 000..77b5137
Binary files /dev/null and b/setuptools_scm-6.4.2.tar.gz differ
diff --git a/tomli-1.0.0.tar.gz b/tomli-1.0.0.tar.gz
new file mode 100644
index 000..bc19ad4
Binary files /dev/null and b/tomli-1.0.0.tar.gz differ
diff --git a/tomli-2.0.1.tar.gz b/tomli-2.0.1.tar.gz
new file mode 100644
index 000..fde81b7
Binary files /dev/null and b/tomli-2.0.1.tar.gz differ
diff --git a/wheel-0.40.0.tar.gz b/wheel-0.40.0.tar.gz
new file mode 100644
index 000..869ba47
Binary files /dev/null and b/wheel-0.40.0.tar.gz differ
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/turnip:turnip-payload-upgrade-to-focal into turnip:master

2023-07-24 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/turnip:turnip-payload-upgrade-to-focal into turnip:master.

Commit message:
VM upgraded from bionic to focal

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/turnip/+git/turnip/+merge/447505
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/turnip:turnip-payload-upgrade-to-focal into turnip:master.
diff --git a/ols-vms.conf b/ols-vms.conf
index bbafdfc..72394bc 100644
--- a/ols-vms.conf
+++ b/ols-vms.conf
@@ -1,6 +1,6 @@
 # Options defined here provide defaults for all sections
 vm.architecture = amd64
-vm.release = bionic
+vm.release = focal
 
 # pygit2
 apt.sources = ppa:launchpad/ppa
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/lpci:lpci-0.2.2 into lpci:main

2023-07-14 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/lpci:lpci-0.2.2 into lpci:main.

Commit message:
New release: lpci 0.2.2

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/lpci/+git/lpcraft/+merge/446858
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lpci:lpci-0.2.2 into lpci:main.
diff --git a/NEWS.rst b/NEWS.rst
index 5a0b3c7..9d6f991 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -2,7 +2,7 @@
 Version history
 ===
 
-0.2.2 (unreleased)
+0.2.2 (2023-07-14)
 ==
 
 - Fix default value for the `root` flag in documentation.
diff --git a/setup.cfg b/setup.cfg
index 1e3172c..71ead96 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [metadata]
 name = lpci
-version = 0.2.2.dev0
+version = 0.2.2
 description = Runner for Launchpad CI jobs
 long_description = file: README.rst
 long_description_content_type = text/x-rst
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:remove-f-string into launchpad:master

2023-07-13 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/launchpad:remove-f-string into 
launchpad:master.

Commit message:
Removed f-string

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/446773
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:remove-f-string into launchpad:master.
diff --git a/lib/lp/code/model/cibuild.py b/lib/lp/code/model/cibuild.py
index fb29c2e..2ee9c85 100644
--- a/lib/lp/code/model/cibuild.py
+++ b/lib/lp/code/model/cibuild.py
@@ -107,9 +107,10 @@ def get_stages(configuration):
 or previous_job not in stages[arch][-1][0]
 ):
 raise CannotBuild(
-f"Job {job_name} would run on {arch},"
-+ f"but the previous job {previous_job}"
-+ "in the same pipeline would not"
+"Job %r would run on %r,"
++ "but the previous job %r"
++ "in the same pipeline would not" % job_name,
+arch,
 )
 jobs[arch].append((job_name, i))
 
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:ftpmaster-charm into launchpad:master

2023-07-10 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/launchpad:ftpmaster-charm into 
launchpad:master.

Commit message:
FTPMaster charms

Ftpmaster publisher and uploader.
Ftpmaster publisher publishes packages to the ubuntu archives,
running scripts contained in the ubuntu-archive-publishing repository.
Ftpmaster uploader process uploads of src packages intended
for publishing to ubuntu archive.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/446413
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:ftpmaster-charm into launchpad:master.
diff --git a/charm/launchpad-ftpmaster-publisher/README.md b/charm/launchpad-ftpmaster-publisher/README.md
new file mode 100644
index 000..1cc4969
--- /dev/null
+++ b/charm/launchpad-ftpmaster-publisher/README.md
@@ -0,0 +1,3 @@
+# Launchpad ftpmaster-publisher
+
+This charm runs Launchpad ftpmaster-publisher.
diff --git a/charm/launchpad-ftpmaster-publisher/charmcraft.yaml b/charm/launchpad-ftpmaster-publisher/charmcraft.yaml
new file mode 100644
index 000..01c2133
--- /dev/null
+++ b/charm/launchpad-ftpmaster-publisher/charmcraft.yaml
@@ -0,0 +1,64 @@
+type: charm
+bases:
+  - build-on:
+- name: ubuntu
+  channel: "20.04"
+  architectures: [amd64]
+run-on:
+- name: ubuntu
+  channel: "20.04"
+  architectures: [amd64]
+parts:
+  charm-wheels:
+source: https://git.launchpad.net/~ubuntuone-hackers/ols-charm-deps/+git/wheels
+source-commit: "59b32ae07f98051385c96d6d8e7e02ca4f197fe5"
+source-submodules: []
+source-type: git
+plugin: dump
+organize:
+  "*": charm-wheels/
+prime:
+  - "-charm-wheels"
+  ols-layers:
+source: https://git.launchpad.net/ols-charm-deps
+source-commit: "56d219f60a293a6c73759b8439ef5fdb11e19d1f"
+source-submodules: []
+source-type: git
+plugin: dump
+organize:
+  "*": layers/
+stage:
+  - layers
+prime:
+  - "-layers"
+  launchpad-layers:
+after:
+  - ols-layers
+source: https://git.launchpad.net/launchpad-layers
+source-commit: "fe273e9f446f84243be2070334cacd03c09da946"
+source-submodules: []
+source-type: git
+plugin: dump
+organize:
+  launchpad-base: layers/layer/launchpad-base
+  launchpad-db: layers/layer/launchpad-db
+  launchpad-payload: layers/layer/launchpad-payload
+  launchpad-publisher-parts: layers/layer/launchpad-publisher-parts
+stage:
+  - layers
+prime:
+  - "-layers"
+  launchpad-ftpmaster-publisher:
+after:
+  - charm-wheels
+  - launchpad-layers
+source: .
+plugin: reactive
+build-snaps: [charm]
+build-packages: [libpq-dev, python3-dev]
+build-environment:
+  - CHARM_LAYERS_DIR: $CRAFT_STAGE/layers/layer
+  - CHARM_INTERFACES_DIR: $CRAFT_STAGE/layers/interface
+  - PIP_NO_INDEX: "true"
+  - PIP_FIND_LINKS: $CRAFT_STAGE/charm-wheels
+reactive-charm-build-arguments: [--binary-wheels-from-source]
diff --git a/charm/launchpad-ftpmaster-publisher/config.yaml b/charm/launchpad-ftpmaster-publisher/config.yaml
new file mode 100644
index 000..3dedb19
--- /dev/null
+++ b/charm/launchpad-ftpmaster-publisher/config.yaml
@@ -0,0 +1,31 @@
+options:
+  active:
+type: boolean
+default: true
+description: If true, enable jobs that may change the database.
+  publisher_parts_repository:
+type: string
+description: Repository URL for the Ubuntu specific scripts. 
+default: lp:ubuntu-archive-publishing
+  publisher_parts_revision: 
+type: int
+description: Revision number for the Ubuntu specific scripts.
+default: 120
+  client_public_key:
+type: string
+description: Client public key.
+default: ""
+  # TEMP
+  build_label:
+type: string
+default: fe329353bc9b398511715c0135e456204a8f39bd
+description: Build label to run.
+  swift_container_name:
+type: string
+default: "launchpad-builds"
+description: TBD
+  swift_storage_url:
+type: string
+default: "https://objectstorage.prodstack5.canonical.com/swift/v1/AUTH_318a449e4c8e40e2865c120a597a9644;
+description: TBD
+  
\ No newline at end of file
diff --git a/charm/launchpad-ftpmaster-publisher/layer.yaml b/charm/launchpad-ftpmaster-publisher/layer.yaml
new file mode 100644
index 000..597af9c
--- /dev/null
+++ b/charm/launchpad-ftpmaster-publisher/layer.yaml
@@ -0,0 +1,19 @@
+includes:
+  - layer:launchpad-db
+  - layer:launchpad-publisher-parts
+repo: https://git.launchpad.net/launchpad
+options:
+  apt:
+packages:
+  - nodejs
+  - python3-convoy
+  ols-pg:
+databases:
+  db:
+name: launchpad_dev
+roles:
+  - publish_ftpmaster
+  - gener

[Launchpad-reviewers] [Merge] ~pelpsi/txpkgupload:txpkgupload-charm into txpkgupload:master

2023-07-05 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/txpkgupload:txpkgupload-charm into 
txpkgupload:master.

Commit message:
Txpkgupload charm created

Listens to FTP and SFTP requests, and processes uploads files into a
temporary directory
This is a subordinate charm, so it will need a master that provides a
`upload-queue-processor` interface to be deployed.

launchpad-layer source-commit should be updated when the related MP is merged.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/txpkgupload/+git/txpkgupload/+merge/446054
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/txpkgupload:txpkgupload-charm into txpkgupload:master.
diff --git a/charm/txpkgupload/README.md b/charm/txpkgupload/README.md
new file mode 100644
index 000..74b90e5
--- /dev/null
+++ b/charm/txpkgupload/README.md
@@ -0,0 +1,23 @@
+# TX (Twisted) Package Upload
+
+Listens to FTP and SFTP requests, and processes uploads files into a
+temporary directory
+
+This is a subordinate charm, so it will need a master that provides a 
+`upload-queue-processor` interface to be deployed. The master should have in
+their `metadata.yaml` something on the lines of:
+
+```yaml
+provides:
+  upload-queue-processor:
+interface: upload-queue-processor
+scope: container
+```
+
+As this is a subordinate charm, it will be deployed to the same machine as its
+master. The charm will not deploy before the relation to its master is set.
+You will need the following relations:
+
+```shell
+juju relate txpkgupload 
+```
diff --git a/charm/txpkgupload/charmcraft.yaml b/charm/txpkgupload/charmcraft.yaml
new file mode 100644
index 000..e49a71f
--- /dev/null
+++ b/charm/txpkgupload/charmcraft.yaml
@@ -0,0 +1,60 @@
+type: charm
+bases:
+  - build-on:
+- name: ubuntu
+  channel: "20.04"
+  architectures: [amd64]
+run-on:
+- name: ubuntu
+  channel: "20.04"
+  architectures: [amd64]
+parts:
+  charm-wheels:
+source: https://git.launchpad.net/~ubuntuone-hackers/ols-charm-deps/+git/wheels
+source-commit: "59b32ae07f98051385c96d6d8e7e02ca4f197fe5"
+source-submodules: []
+source-type: git
+plugin: dump
+organize:
+  "*": charm-wheels/
+prime:
+  - "-charm-wheels"
+  ols-layers:
+source: https://git.launchpad.net/ols-charm-deps
+source-commit: "56d219f60a293a6c73759b8439ef5fdb11e19d1f"
+source-submodules: []
+source-type: git
+plugin: dump
+organize:
+  "*": layers/
+stage:
+  - layers
+prime:
+  - "-layers"
+  launchpad-layers:
+after:
+  - ols-layers
+source: https://git.launchpad.net/~ines-almeida/launchpad-layers
+source-commit: "685b45e63ebb56cf505186be1ebba7d914ce60e9"
+source-submodules: []
+source-type: git
+plugin: dump
+organize:
+  upload-queue-processor: layers/interface/upload-queue-processor
+stage:
+  - layers
+prime:
+  - "-layers"
+  txpkgupload:
+after:
+  - charm-wheels
+  - launchpad-layers
+source: .
+plugin: reactive
+build-snaps: [charm/2.x/stable]
+build-packages: [libpq-dev]
+build-environment:
+  - CHARM_LAYERS_DIR: $CRAFT_STAGE/layers/layer
+  - CHARM_INTERFACES_DIR: $CRAFT_STAGE/layers/interface
+  - PIP_NO_INDEX: "true"
+  - PIP_FIND_LINKS: $CRAFT_STAGE/charm-wheels
diff --git a/charm/txpkgupload/config.yaml b/charm/txpkgupload/config.yaml
new file mode 100644
index 000..aba582e
--- /dev/null
+++ b/charm/txpkgupload/config.yaml
@@ -0,0 +1,25 @@
+options:
+  ftp_port:
+type: int
+default: 2221
+description: The port to run the FTP server on.
+  sftp_authentication_endpoint:
+type: string
+default: http://xmlrpc-private.launchpad.dev:8087/authserver
+description: The URL of the XML-RPC endpoint for authentication handling of SSH users.
+  sftp_host_key_private:
+type: string
+default: src/txpkgupload/tests/txpkgupload-sftp
+description: The absolute path to the private key used for the SFTP server.
+  sftp_host_key_public:
+type: string
+default: src/txpkgupload/tests/txpkgupload-sftp.pub
+description: The absolute path to the public key used for the SFTP server.
+  sftp_port:
+type: string
+default: tcp:5023
+description: The port to run the SFTP server on, expressed in Twisted's "strpo mini-language.
+  reporter:
+type: string
+default: local
+description: The reporter used when generating OOPS reports.
\ No newline at end of file
diff --git a/charm/txpkgupload/layer.yaml b/charm/txpkgupload/layer.yaml
new file mode 100644
index 000..f959e97
--- /dev/null
+++ b/charm/txpkgupload/layer.yaml
@@ -0,0 +1,17 @@
+includes:
+  - layer:basic
+  - layer:ols
+  - interface:upload-queue-processor
+repo: https://git.launchpa

[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:send-bug-notifications-opsees-list-index-out-of-range into launchpad:master

2023-06-21 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:send-bug-notifications-opsees-list-index-out-of-range into 
launchpad:master.

Commit message:
Fixed list index out of range

filters_by_person[x] set was replaced every iteration.
Now it's updated using the "update" set function.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/445114
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:send-bug-notifications-opsees-list-index-out-of-range into 
launchpad:master.
diff --git a/lib/lp/bugs/model/bugnotification.py b/lib/lp/bugs/model/bugnotification.py
index bb51a63..7078cda 100644
--- a/lib/lp/bugs/model/bugnotification.py
+++ b/lib/lp/bugs/model/bugnotification.py
@@ -327,10 +327,12 @@ class BugNotificationSet:
 ] = filter_description
 filter_ids.append(filter_id)
 
-filters_by_person[source_person_id] = {
-(i, filter_id)
-for i in source_person_id_map[source_person_id]["sources"]
-}
+filters_by_person[source_person_id].update(
+{
+(i, filter_id)
+for i in source_person_id_map[source_person_id]["sources"]
+}
+)
 
 # Remaining notifications have no filters
 source_filter_ids = filters_by_person.keys()
@@ -392,7 +394,10 @@ class BugNotificationSet:
 for recipient_data in recipient_id_map.values():
 # Getting filtered sources
 
-if recipient_data["filters"]:
+if (
+recipient_data["filters"]
+and filters_by_person[recipient_data["principal"].id]
+):
 filter_descriptions = [
 description
 for description in recipient_data["filters"].values()
diff --git a/lib/lp/bugs/scripts/tests/test_bugnotification.py b/lib/lp/bugs/scripts/tests/test_bugnotification.py
index b9b0a0a..a2efef1 100644
--- a/lib/lp/bugs/scripts/tests/test_bugnotification.py
+++ b/lib/lp/bugs/scripts/tests/test_bugnotification.py
@@ -54,6 +54,7 @@ from lp.bugs.scripts.bugnotification import (
 notification_comment_batches,
 process_deferred_notifications,
 )
+from lp.registry.enums import TeamMembershipPolicy
 from lp.registry.interfaces.person import IPersonSet
 from lp.registry.interfaces.product import IProductSet
 from lp.services.config import config
@@ -1533,6 +1534,7 @@ class TestSendBugNotifications(TestCaseWithFactory):
 subscription = bug.default_bugtask.target.addBugSubscription(
 team, team_owner
 )
+print(subscription)
 # Take team subscription's filter
 subscription_filter = subscription.bug_filters.one()
 bug.default_bugtask.target.addBugSubscription(
@@ -1572,3 +1574,61 @@ class TestSendBugNotifications(TestCaseWithFactory):
 self.assertEqual(
 "team-participant", messages[1]["X-Launchpad-Message-For"]
 )
+
+def test_team_subscription_with_multiple_filters(self):
+
+team_owner = self.factory.makePerson(
+name="team-owner-name", email="team-ow...@canonical.com"
+)
+
+bug_watcher = self.factory.makePerson(
+name="bug-watcher-name", email="bug-watc...@canonical.com"
+)
+
+team = self.factory.makeTeam(
+name="team-name",
+owner=team_owner,
+members=[bug_watcher, team_owner],
+membership_policy=TeamMembershipPolicy.RESTRICTED,
+)
+
+bug = self.factory.makeBug(owner=team_owner)
+
+subscription = bug.default_bugtask.target.addSubscription(
+team, team_owner
+)
+
+message = getUtility(IMessageSet).fromText(
+"subject",
+"a comment.",
+team_owner,
+datecreated=self.ten_minutes_ago,
+)
+recipients = bug.getBugNotificationRecipients()
+notification = getUtility(IBugNotificationSet).addNotification(
+bug=bug,
+is_comment=True,
+message=message,
+recipients=recipients,
+activity=None,
+)
+
+bug_filter = subscription.newBugFilter()
+bug_filter.description = "New Filter"
+BugNotificationFilter(
+bug_notification=notification,
+bug_subscription_filter=bug_filter,
+)
+BugSubscriptionFilterMute(
+person=bug_watcher,
+filter=bug_filter,
+)
+notification = self.notification_set.getNotificationsToSend()
+
+pending_notification = get_email_notifications(notification)

[Launchpad-reviewers] [Merge] ~pelpsi/launchpad-layers:launchpad-publisher-parts into launchpad-layers:main

2023-06-14 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad-layers:launchpad-publisher-parts into launchpad-layers:main.

Commit message:
Added launchpad-publisher-parts layer

Added a new layer that will be used by the publisher charm to call run-parts 
algorithm on a given repository with a given revision number



Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-layers/+git/launchpad-layers/+merge/444721
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad-layers:launchpad-publisher-parts into launchpad-layers:main.
diff --git a/launchpad-publisher-parts/config.yaml b/launchpad-publisher-parts/config.yaml
new file mode 100644
index 000..e69de29
--- /dev/null
+++ b/launchpad-publisher-parts/config.yaml
diff --git a/launchpad-publisher-parts/icon.svg b/launchpad-publisher-parts/icon.svg
new file mode 100644
index 000..b2889cc
--- /dev/null
+++ b/launchpad-publisher-parts/icon.svg
@@ -0,0 +1 @@
+http://www.w3.org/2000/svg; viewBox="0 0 165.39062 165.39062">.cls-1{fill:#e9500e;}.cls-2{fill:#fff;}
\ No newline at end of file
diff --git a/launchpad-publisher-parts/layer.yaml b/launchpad-publisher-parts/layer.yaml
new file mode 100644
index 000..69f7ca7
--- /dev/null
+++ b/launchpad-publisher-parts/layer.yaml
@@ -0,0 +1,7 @@
+includes:
+  - layer:basic
+options:
+  launchpad-publisher-parts:
+repository: lp:ubuntu-archive-publishing
+revision: 123
+repo: https://git.launchpad.net/launchpad-layers
diff --git a/launchpad-publisher-parts/lib/charms/launchpad/parts.py b/launchpad-publisher-parts/lib/charms/launchpad/parts.py
new file mode 100644
index 000..e09e6b3
--- /dev/null
+++ b/launchpad-publisher-parts/lib/charms/launchpad/parts.py
@@ -0,0 +1,28 @@
+# Copyright 2022 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+import os.path
+import subprocess
+
+from charmhelpers.core import hookenv
+
+
+# Get bzr branch at given revision
+def get_bzr_repository(repository, revision=-1):
+hookenv.log("Getting " + repository + " -r " + str(revision))
+
+bzr_cmd = "bzr branch " + repository
+rev_arg = ""
+if revision:
+rev_arg = " -r " + str(revision)
+bzr_cmd += rev_arg
+
+subprocess.check_call(bzr_cmd, shell=True)
+
+
+# Call run-parts algorithm on a given folder
+def run_parts_on_folder(wd="."):
+hookenv.log("Calling run-parts in folder " + wd)
+
+if os.path.isdir(wd):
+subprocess.check_call(["sudo", "run-parts", wd])
diff --git a/launchpad-publisher-parts/reactive/launchpad-publisher-parts.py b/launchpad-publisher-parts/reactive/launchpad-publisher-parts.py
new file mode 100644
index 000..c779655
--- /dev/null
+++ b/launchpad-publisher-parts/reactive/launchpad-publisher-parts.py
@@ -0,0 +1,26 @@
+# Copyright 2022 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+from charms.launchpad.parts import get_bzr_repository, run_parts_on_folder
+from charms.layer import options
+from charms.reactive import set_flag, when_not
+
+
+def run_parts_on_repository():
+repository = (
+options().get("launchpad-publisher-parts", {}).get("repository", "")
+)
+revision = (
+options().get("launchpad-publisher-parts", {}).get("revision", "")
+)
+
+# Expecting a bzr repository lp:repo-name
+folder = repository.split(":")[1]
+get_bzr_repository(repository, revision)
+run_parts_on_folder(folder)
+
+
+@when_not("launchpad.publisher-parts.configured")
+def configure():
+run_parts_on_repository()
+set_flag("launchpad.publisher-parts.configured")
diff --git a/launchpad-publisher-parts/templates/macros.j2 b/launchpad-publisher-parts/templates/macros.j2
new file mode 100644
index 000..8cddb14
--- /dev/null
+++ b/launchpad-publisher-parts/templates/macros.j2
@@ -0,0 +1,6 @@
+{#- An optional configuration entry. #}
+{%- macro opt(name, value) %}
+{%-   if value is defined and value is not none %}
+{{ name }}: {{ value }}
+{%-   endif %}
+{%- endmacro %}
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] txpkgupload:update-wheel-command-makefile into txpkgupload:master

2023-06-13 Thread Simone Pelosi
LGTM! 
-- 
https://code.launchpad.net/~lazr-developers/txpkgupload/+git/txpkgupload/+merge/444615
Your team Launchpad code reviewers is requested to review the proposed merge of 
txpkgupload:update-wheel-command-makefile into txpkgupload:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:improve-logging-for-the-account-close-script into launchpad:master

2023-05-16 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:improve-logging-for-the-account-close-script into 
launchpad:master.

Commit message:
Added a log that nofifies when the account is closed

The new log notifies when the account is closed before committing the 
transaction.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/442988
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:improve-logging-for-the-account-close-script into 
launchpad:master.
diff --git a/lib/lp/registry/scripts/closeaccount.py b/lib/lp/registry/scripts/closeaccount.py
index 2a5657a..73510a0 100644
--- a/lib/lp/registry/scripts/closeaccount.py
+++ b/lib/lp/registry/scripts/closeaccount.py
@@ -626,6 +626,7 @@ def close_account(username, log):
 "User %s is still referenced" % person_name
 )
 
+log.info("%s's account closed" % person_name)
 return True
 
 
diff --git a/lib/lp/registry/scripts/tests/test_closeaccount.py b/lib/lp/registry/scripts/tests/test_closeaccount.py
index e9cd611..9177ddc 100644
--- a/lib/lp/registry/scripts/tests/test_closeaccount.py
+++ b/lib/lp/registry/scripts/tests/test_closeaccount.py
@@ -83,9 +83,9 @@ class TestCloseAccount(TestCaseWithFactory):
 self.addDetail("log", script.logger.content)
 flush_database_caches()
 
-def makePopulatedUser(self):
+def makePopulatedUser(self, name=None):
 """Return a person and account linked to some personal information."""
-person = self.factory.makePerson(karma=10)
+person = self.factory.makePerson(name=name, karma=10)
 self.assertEqual(AccountStatus.ACTIVE, person.account.status)
 self.assertNotEqual([], list(person.account.openid_identifiers))
 self.factory.makeBugTask().transitionToAssignee(person, validate=False)
@@ -201,6 +201,23 @@ class TestCloseAccount(TestCaseWithFactory):
 )
 self.assertNotRemoved(account_id, person_id)
 
+def test_close_account_logs(self):
+person, person_id, account_id = self.makePopulatedUser(
+name="test-account-to-close"
+)
+script = self.makeScript([person.name])
+with dbuser("launchpad"):
+self.runScript(script)
+self.assertRemoved(account_id, person_id)
+self.assertIn(
+"Closing test-account-to-close's account",
+script.logger.getLogBuffer(),
+)
+self.assertIn(
+"test-account-to-close's account closed",
+script.logger.getLogBuffer(),
+)
+
 def test_single_by_name(self):
 person, person_id, account_id = self.makePopulatedUser()
 script = self.makeScript([person.name])
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:muted-subscription-bug into launchpad:master

2023-05-15 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/launchpad:muted-subscription-bug 
into launchpad:master.

Commit message:
Added new logic to filter BugNotificationRecipient

filters_by_person (dictionary) is the new data structure introduced:
key is the person_id and the value is a set of tuple with the following format 
(BugNotificationRecipe, filter_id).
Thanks to that structure we can filter the muted notifications simply by 
removing them from the filters_by_person[person_id] set.
The remaining notifications will be sent to the user.

LP: #2019428

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #2019428 in Launchpad itself: "Not receiving (proper) emails for packages 
I'm subscribed to"
  https://bugs.launchpad.net/launchpad/+bug/2019428

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/442903
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:muted-subscription-bug into launchpad:master.
diff --git a/lib/lp/bugs/model/bugnotification.py b/lib/lp/bugs/model/bugnotification.py
index 9634c6a..1500351 100644
--- a/lib/lp/bugs/model/bugnotification.py
+++ b/lib/lp/bugs/model/bugnotification.py
@@ -10,6 +10,7 @@ __all__ = [
 "BugNotificationSet",
 ]
 
+from collections import defaultdict
 from datetime import datetime, timedelta, timezone
 
 from storm.expr import In, Join, LeftJoin
@@ -255,6 +256,8 @@ class BugNotificationSet:
 # First we get some intermediate data structures set up.
 source_person_id_map = {}
 recipient_id_map = {}
+notifications_by_source = defaultdict(set)
+
 for recipient, sources in recipient_to_sources.items():
 if recipient.id in muted_person_ids:
 continue
@@ -279,10 +282,11 @@ class BugNotificationSet:
 }
 source_person_id_map[person_id] = data
 data["sources"].add(source)
+notifications_by_source[person_id].add(source)
 # Now we actually look for the filters.
 store = IStore(BugSubscriptionFilter)
 source = store.using(
-BugSubscriptionFilter,
+(BugSubscriptionFilter,),
 Join(
 BugNotificationFilter,
 BugSubscriptionFilter.id
@@ -312,25 +316,49 @@ class BugNotificationSet:
 list(source_person_id_map),
 ),
 )
+
 filter_ids = []
+no_filter_marker = -1
+
+# Associate filters to each notification to facilitate search
+filters_by_person = defaultdict(set)
 # Record the filters for each source.
+source_filter_ids = set()
 for source_person_id, filter_id, filter_description in filter_data:
+source_filter_ids.add(source_person_id)
 source_person_id_map[source_person_id]["filters"][
 filter_id
 ] = filter_description
 filter_ids.append(filter_id)
 
+filters_by_person[source_person_id] = {
+(i, filter_id)
+for i in notifications_by_source[source_person_id]
+}
+
+for id in source_filter_ids:
+del notifications_by_source[id]
+
+# Remaining notifications have no filters
+for key in notifications_by_source:
+filters_by_person[key] = {
+(i, no_filter_marker) for i in notifications_by_source[key]
+}
 # This is only necessary while production and sample data have
 # structural subscriptions without filters.  Assign the filters to
 # each recipient.
-no_filter_marker = -1
-
 for recipient_data in recipient_id_map.values():
 for source_person_id in recipient_data["source person ids"]:
 recipient_data["filters"].update(
 source_person_id_map[source_person_id]["filters"]
 or {no_filter_marker: None}
 )
+
+filters_by_person[
+recipient_data["principal"].id
+] = filters_by_person[recipient_data["principal"].id].union(
+filters_by_person[source_person_id]
+)
 if filter_ids:
 # Now we get the information about subscriptions that might be
 # filtered and take that into account.
@@ -355,19 +383,37 @@ class BugNotificationSet:
 del recipient_id_map[person_id]["filters"][
 no_filter_marker
 ]
+
+# Remove notification if it's muted
+filtered_set = set()
+for tuple in filters_by_person[person_id]:
+if tuple[1] != filter_id:
+filtered_set.add(tuple)
+ 

[Launchpad-reviewers] [Merge] ~pelpsi/lpci:conda-build-outside-env into lpci:main

2023-05-08 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/lpci:conda-build-outside-env into 
lpci:main.

Commit message:
Fixed conda-build plugin

lpci conda build plugin should install and run conda-build outside of a conda 
environment

LP: #1978717

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1978717 in lpci: "lpcraft conda build plugin should install and run 
conda-build outside of a conda environment"
  https://bugs.launchpad.net/lpci/+bug/1978717

For more details, see:
https://code.launchpad.net/~pelpsi/lpci/+git/lpcraft/+merge/442492
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lpci:conda-build-outside-env into lpci:main.
diff --git a/NEWS.rst b/NEWS.rst
index 34f9f96..d4515c2 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -2,6 +2,12 @@
 Version history
 ===
 
+0.1.3 (unreleased)
+==
+
+- Fix conda-build plugin to install and run outside
+  of a conda environment.
+
 0.1.2 (2023-05-02)
 ==
 
diff --git a/lpci/plugin/tests/test_plugins.py b/lpci/plugin/tests/test_plugins.py
index b0c5844..144286d 100644
--- a/lpci/plugin/tests/test_plugins.py
+++ b/lpci/plugin/tests/test_plugins.py
@@ -364,22 +364,13 @@ class TestPlugins(CommandBaseTestCase):
 /tmp/miniconda.sh -b
 fi
 export PATH=$HOME/miniconda3/bin:$PATH
-conda remove --all -q -y -n $CONDA_ENV
-conda create -n $CONDA_ENV -q -y -c conda-forge -c defaults PYTHON=3.8 mamba pip
-source activate $CONDA_ENV
+conda install -q -y -c conda-forge -c defaults PYTHON=3.8 mamba pip
 """  # noqa:E501
 )
 
-run_command = dedent(
-"""
-export PATH=$HOME/miniconda3/bin:$PATH
-source activate $CONDA_ENV
-pip install --upgrade pytest
-"""
-)
+run_command = dedent("""pip install --upgrade pytest\n""")
 post_run_command = (
-"export PATH=$HOME/miniconda3/bin:$PATH; "
-"source activate $CONDA_ENV; conda env export"
+"export PATH=$HOME/miniconda3/bin:$PATH; conda env export"
 )
 
 self.run_command("run")
@@ -563,22 +554,18 @@ class TestPlugins(CommandBaseTestCase):
 /tmp/miniconda.sh -b
 fi
 export PATH=$HOME/miniconda3/bin:$PATH
-conda remove --all -q -y -n $CONDA_ENV
-conda create -n $CONDA_ENV -q -y -c conda-forge -c defaults -c https://user:p...@canonical.example.com/artifactory/soss-conda-stable-local/ PYTHON=3.8 conda-build mamba pip
-source activate $CONDA_ENV
+conda install -q -y -c conda-forge -c defaults -c https://user:p...@canonical.example.com/artifactory/soss-conda-stable-local/ PYTHON=3.8 conda-build mamba pip
 """  # noqa:E501
 )
 run_command = dedent(
 """
 export PATH=$HOME/miniconda3/bin:$PATH
-source activate $CONDA_ENV
 conda-build --no-anaconda-upload --output-folder dist -c conda-forge -c defaults -c https://user:p...@canonical.example.com/artifactory/soss-conda-stable-local/ info/recipe/parent
 pip install --upgrade pytest
 """  # noqa: E501
 )
 post_run_command = (
-"export PATH=$HOME/miniconda3/bin:$PATH; "
-"source activate $CONDA_ENV; conda env export"
+"export PATH=$HOME/miniconda3/bin:$PATH; conda env export"
 )
 
 self.run_command(
@@ -866,7 +853,6 @@ class TestPlugins(CommandBaseTestCase):
 run_command = dedent(
 """
 export PATH=$HOME/miniconda3/bin:$PATH
-source activate $CONDA_ENV
 conda-build --no-anaconda-upload --output-folder dist -c conda-forge -c defaults -m info/recipe/parent/conda_build_config.yaml -m info/recipe/conda_build_config.yaml info/recipe/parent
 pip install --upgrade pytest
 """  # noqa: E501
diff --git a/lpci/plugins/plugins.py b/lpci/plugins/plugins.py
index 6fe88a2..bf1c3ed 100644
--- a/lpci/plugins/plugins.py
+++ b/lpci/plugins/plugins.py
@@ -206,29 +206,19 @@ class MiniCondaPlugin(BasePlugin):
 /tmp/miniconda.sh -b
 fi
 export PATH=$HOME/miniconda3/bin:$PATH
-conda remove --all -q -y -n $CONDA_ENV
-conda create -n $CONDA_ENV -q -y {conda_channels} {' '.join(self.conda_packages)}
-source activate $CONDA_ENV
+conda install -q -y {conda_channels} {' '.join(self.conda_packages)}
 {run}"""  # noqa:E501
 )
 
 @hookimpl  # type: ignore
 def lpci_execute_run(self) -> str:
 run = self.config.run or ""
-return textwrap.dedent(
- 

[Launchpad-reviewers] [Merge] ~pelpsi/lpci:add-dev0-suffix-to-docs into lpci:main

2023-04-21 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/lpci:add-dev0-suffix-to-docs into 
lpci:main.

Commit message:
Added "dev0" suffix to docs

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/lpci/+git/lpcraft/+merge/441690
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lpci:add-dev0-suffix-to-docs into lpci:main.
diff --git a/docs/release-process.rst b/docs/release-process.rst
index c458ab4..0c38ca8 100644
--- a/docs/release-process.rst
+++ b/docs/release-process.rst
@@ -41,6 +41,11 @@ How to create a new release
 
 Some additional information
 ***
+- It is a best practice to use ``dev0`` version's suffix defining a new
+  development version into ``setup.cfg`` after a release,
+  so when building that version for testing, it does not show the old version number.
+  Once we want to release, we remove the suffix, to indicate that
+  this is no longer a development version.
 
 - members of the Launchpad team can use the ``Request builds`` button
   on that recipe if they need updated builds urgently
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/lpci:release-0.1.1 into lpci:main

2023-04-21 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/lpci:release-0.1.1 into lpci:main.

Commit message:
Release 0.1.1

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/lpci/+git/lpcraft/+merge/441655
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lpci:release-0.1.1 into lpci:main.
diff --git a/NEWS.rst b/NEWS.rst
index 45f0dde..b88d8e0 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -2,7 +2,7 @@
 Version history
 ===
 
-0.1.1 (unreleased)
+0.1.1 (2023-04-21)
 ==
 - Fix the yaml formatting in the snap deprecated format warning.
 
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/lpci:jobs-cannot-run-as-root into lpci:main

2023-04-20 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/lpci:jobs-cannot-run-as-root into 
lpci:main.

Commit message:
Add a root flag

New root flag to choose whether to run commands as root or as default user 
(_lpci).
Lpci runs jobs as root inside the container.
However, there are some reasonable jobs that call code that refuses to run as 
root.

LP: #1982954


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1982954 in lpci: "Some jobs cannot run as root"
  https://bugs.launchpad.net/lpci/+bug/1982954

For more details, see:
https://code.launchpad.net/~pelpsi/lpci/+git/lpcraft/+merge/441539
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lpci:jobs-cannot-run-as-root into lpci:main.
diff --git a/NEWS.rst b/NEWS.rst
index ba2012b..45f0dde 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -9,6 +9,8 @@ Version history
 - Fix ``policy-rc.d`` issue preventing services
   from running into the container.
 
+- Add a ``root`` flag.
+
 0.1.0 (2023-04-18)
 ==
 
diff --git a/docs/configuration.rst b/docs/configuration.rst
index 65b0b5d..db9f589 100644
--- a/docs/configuration.rst
+++ b/docs/configuration.rst
@@ -61,6 +61,10 @@ Job definitions
 `/etc/apt/sources.list`.
 Also see the :ref:`package-repositories` section below.
 
+``root`` (optional)
+If False, allow running commands as default user (_lpci).
+Default value: True.
+
 ``snaps`` (optional)
 Snaps to install as dependencies of this job.
 Also see the :ref:`snap-properties` section below.
diff --git a/lpci/commands/run.py b/lpci/commands/run.py
index d6c65b2..ef29525 100644
--- a/lpci/commands/run.py
+++ b/lpci/commands/run.py
@@ -433,8 +433,14 @@ def _run_instance_command(
 host_architecture: str,
 remote_cwd: Path,
 environment: Optional[Dict[str, Optional[str]]],
+root: bool = True,
 ) -> None:
 full_run_cmd = ["bash", "--noprofile", "--norc", "-ec", command]
+if not root:
+prefix = ["runuser", "-u", env.get_default_user(), "--"]
+prefix.extend(full_run_cmd)
+full_run_cmd = prefix
+
 emit.progress("Running command for the job...")
 original_mode = emit.get_mode()
 if original_mode == EmitterMode.BRIEF:
@@ -475,6 +481,11 @@ def _run_job(
 # XXX jugmac00 2022-04-27: we should create a configuration object to be
 # passed in and not so many arguments
 job = config.jobs[job_name][job_index]
+root = job.root
+
+# workaround necessary to please coverage
+assert isinstance(root, bool)
+
 host_architecture = get_host_architecture()
 if host_architecture not in job.architectures:
 return
@@ -540,6 +551,7 @@ def _run_job(
 series=job.series,
 architecture=host_architecture,
 gpu_nvidia=gpu_nvidia,
+root=root,
 ) as instance:
 snaps = list(itertools.chain(*pm.hook.lpci_install_snaps()))
 for snap in snaps:
@@ -583,6 +595,7 @@ def _run_job(
 host_architecture=host_architecture,
 remote_cwd=remote_cwd,
 environment=environment,
+root=root,
 )
 if config.license:
 if not job.output:
diff --git a/lpci/commands/tests/test_run.py b/lpci/commands/tests/test_run.py
index 07ae61b..c47f1e7 100644
--- a/lpci/commands/tests/test_run.py
+++ b/lpci/commands/tests/test_run.py
@@ -3537,6 +3537,55 @@ class TestRun(RunBaseTestCase):
 remote="test-remote",
 )
 
+@patch("lpci.commands.run.get_provider")
+@patch("lpci.commands.run.get_host_architecture", return_value="amd64")
+def test_root_field(self, mock_get_host_architecture, mock_get_provider):
+launcher = Mock(spec=launch)
+provider = makeLXDProvider(lxd_launcher=launcher)
+mock_get_provider.return_value = provider
+execute_run = launcher.return_value.execute_run
+execute_run.return_value = subprocess.CompletedProcess("_lpci", 0)
+config = dedent(
+"""
+pipeline:
+- build
+
+jobs:
+build:
+root: False
+series: focal
+architectures: amd64
+run: whoami
+"""
+)
+Path(".launchpad.yaml").write_text(config)
+
+result = self.run_command("run")
+
+self.assertEqual(0, result.exit_code)
+self.assertEqual(
+[
+call(
+[
+"runuser",
+"-u",
+"_lpci",
+"--",
+"bash",
+

[Launchpad-reviewers] [Merge] ~pelpsi/lpci:policy-rc-preventing-services-from-running into lpci:main

2023-04-19 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/lpci:policy-rc-preventing-services-from-running into lpci:main.

Commit message:
Removed policy-rc.d

The presence of the following file is preventing services from running in CI.

LP: #1995954


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1995954 in lpci: "local policy-rc.d file preventing services from 
running in CI"
  https://bugs.launchpad.net/lpci/+bug/1995954

For more details, see:
https://code.launchpad.net/~pelpsi/lpci/+git/lpcraft/+merge/441458
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lpci:policy-rc-preventing-services-from-running into lpci:main.
diff --git a/lpci/providers/_lxd.py b/lpci/providers/_lxd.py
index 45ef5ff..0568a0d 100644
--- a/lpci/providers/_lxd.py
+++ b/lpci/providers/_lxd.py
@@ -348,6 +348,12 @@ class LXDProvider(Provider):
 ],
 check=True,
 )
+self._internal_execute_run(
+instance,
+instance_name,
+["rm", "/usr/local/sbin/policy-rc.d"],
+check=True,
+)
 except subprocess.CalledProcessError as error:
 raise CommandError(str(error)) from error
 finally:
diff --git a/lpci/providers/tests/test_lxd.py b/lpci/providers/tests/test_lxd.py
index 39a0245..af7d4f4 100644
--- a/lpci/providers/tests/test_lxd.py
+++ b/lpci/providers/tests/test_lxd.py
@@ -498,6 +498,17 @@ class TestLXDProvider(TestCase):
 runner=subprocess.run,
 check=True,
 ),
+call().lxc.exec(
+instance_name=expected_instance_name,
+command=[
+"rm",
+"/usr/local/sbin/policy-rc.d",
+],
+project="test-project",
+remote="test-remote",
+runner=subprocess.run,
+check=True,
+),
 call().unmount(target=Path("/root/tmp-project")),
 ],
 mock_launcher.mock_calls,
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/lpci:launch-debug-shell-on-exception into lpci:main

2023-04-17 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/lpci:launch-debug-shell-on-exception 
into lpci:main.

Commit message:
Added new debug shell

Launch debug shell on exception

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/lpci/+git/lpcraft/+merge/441174
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lpci:launch-debug-shell-on-exception into lpci:main.
diff --git a/lpci/main.py b/lpci/main.py
index c84126d..3cb9222 100644
--- a/lpci/main.py
+++ b/lpci/main.py
@@ -4,6 +4,8 @@
 """Main entry point."""
 
 import logging
+import pathlib
+import subprocess
 import sys
 from typing import List, Optional
 
@@ -35,6 +37,22 @@ def _configure_logger(name: str) -> None:
 logger.setLevel(logging.DEBUG)
 
 
+def _launch_shell(
+*, cwd: Optional[pathlib.Path] = None, error: Exception
+) -> None:
+"""Launch a user shell for debugging environment.
+
+:param cwd: Working directory to start user in.
+"""
+emit.progress(
+"Launching debug shell on build environment...", permanent=True
+)
+
+emit.error(error)
+
+subprocess.run(["bash"], check=False, cwd=cwd)
+
+
 _configure_logger("craft_providers")
 
 
@@ -54,6 +72,7 @@ def main(argv: Optional[List[str]] = None) -> int:
 if argv is None:
 argv = sys.argv[1:]
 
+debug_shell = False
 emit.init(EmitterMode.BRIEF, "lpci", f"Starting {lpci_version}")
 command_groups = [
 CommandGroup("Basic", _basic_commands),
@@ -67,7 +86,14 @@ def main(argv: Optional[List[str]] = None) -> int:
 "-V",
 "--version",
 "Show version information and exit",
-)
+),
+GlobalArgument(
+"debugshell",
+"flag",
+"-ds",
+"--debug-shell",
+"Shell into the environment if the run fails",
+),
 ]
 
 # dispatcher = Dispatcher(
@@ -94,6 +120,8 @@ def main(argv: Optional[List[str]] = None) -> int:
 default_command=RunCommand,
 )
 global_args = dispatcher.pre_parse_args(argv)
+if global_args["debugshell"]:
+debug_shell = True
 if global_args["version"]:
 emit.message(lpci_version)
 emit.ended_ok()
@@ -109,7 +137,10 @@ def main(argv: Optional[List[str]] = None) -> int:
 emit.ended_ok()
 ret = 0
 except CraftError as e:
-emit.error(e)
+if debug_shell:
+_launch_shell(error=e)
+else:
+emit.error(e)
 ret = e.retcode
 except KeyboardInterrupt as e:
 error = CraftError("Interrupted.")
@@ -119,7 +150,10 @@ def main(argv: Optional[List[str]] = None) -> int:
 except Exception as e:
 error = CraftError(f"lpci internal error: {e!r}")
 error.__cause__ = e
-emit.error(error)
+if debug_shell:
+_launch_shell(error=error)
+else:
+emit.error(error)
 ret = 1
 else:
 emit.ended_ok()
diff --git a/lpci/tests/test_main.py b/lpci/tests/test_main.py
index b67da1e..025cc06 100644
--- a/lpci/tests/test_main.py
+++ b/lpci/tests/test_main.py
@@ -78,6 +78,52 @@ class TestMain(TestCase):
 emitter.recorder.interactions[-1],
 )
 
+@patch("lpci.commands.run.RunCommand.run")
+def test_debug_shell_mode_exception(self, mock_run):
+self.useFixture(MockPatch("sys.argv", ["lpci", "--debug-shell"]))
+mock_run.side_effect = RuntimeError()
+
+with RecordingEmitterFixture() as emitter:
+ret = main()
+
+self.assertEqual(1, ret)
+self.assertEqual(
+call(
+"progress",
+"Launching debug shell on build environment...",
+permanent=True,
+),
+emitter.recorder.interactions[-2],
+)
+self.assertEqual(
+call("error", CraftError("lpci internal error: RuntimeError()")),
+emitter.recorder.interactions[-1],
+)
+
+@patch("lpci.commands.run.RunCommand.run")
+def test_debug_shell_mode_craft_exception(self, mock_run):
+self.useFixture(MockPatch("sys.argv", ["lpci", "--debug-shell"]))
+mock_run.side_effect = CraftError(
+"lpci internal error: RuntimeError()"
+)
+
+with RecordingEmitterFixture() as emitter:
+ret = main()
+
+self.assertEqual(1, ret)
+self.assertEqual(
+call(
+"progress",
+  

[Launchpad-reviewers] [Merge] ~pelpsi/lpci:debug-shell-on-exception into lpci:main

2023-04-14 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/lpci:debug-shell-on-exception into 
lpci:main.

Commit message:
Added new debug shell

Shell into the environment if the run fails.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/lpci/+git/lpcraft/+merge/441108
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lpci:debug-shell-on-exception into lpci:main.
diff --git a/lpci/tests/test_main.py b/lpci/tests/test_main.py
index b67da1e..d35b58b 100644
--- a/lpci/tests/test_main.py
+++ b/lpci/tests/test_main.py
@@ -78,6 +78,30 @@ class TestMain(TestCase):
 emitter.recorder.interactions[-1],
 )
 
+@patch("lpcraft.commands.run.RunCommand.run")
+def test_debug_shell_mode(self, mock_run):
+self.useFixture(MockPatch("sys.argv", ["lpcraft", "--debug-shell"]))
+mock_run.side_effect = RuntimeError()
+
+with RecordingEmitterFixture() as emitter:
+ret = main()
+
+self.assertEqual(1, ret)
+self.assertEqual(
+call(
+"progress",
+"Launching shell on build environment...",
+permanent=True,
+),
+emitter.recorder.interactions[-2],
+)
+self.assertEqual(
+call(
+"error", CraftError("lpcraft internal error: RuntimeError()")
+),
+emitter.recorder.interactions[-1],
+)
+
 def test_quiet_mode(self):
 # temporary test until cli API is set and a more meaningful test is
 # possible
diff --git a/lpcraft/main.py b/lpcraft/main.py
new file mode 100644
index 000..cffa6c4
--- /dev/null
+++ b/lpcraft/main.py
@@ -0,0 +1,166 @@
+<<<<<<< lpcraft/main.py
+===
+# Copyright 2021 Canonical Ltd.  This software is licensed under the
+# GNU General Public License version 3 (see the file LICENSE).
+
+"""Main entry point."""
+
+import logging
+import pathlib
+import subprocess
+import sys
+from typing import List, Optional
+
+from craft_cli import (
+ArgumentParsingError,
+CommandGroup,
+CraftError,
+Dispatcher,
+EmitterMode,
+GlobalArgument,
+ProvideHelpException,
+emit,
+)
+
+from lpcraft._version import version_description as lpcraft_version
+from lpcraft.commands.clean import CleanCommand
+from lpcraft.commands.release import ReleaseCommand
+from lpcraft.commands.run import RunCommand, RunOneCommand
+from lpcraft.commands.version import VersionCommand
+
+
+def _configure_logger(name: str) -> None:
+"""Configure a logger for use with craft-cli.
+
+Setting up a library's logger in DEBUG level causes its content to be
+grabbed by craft-cli's Emitter.
+"""
+logger = logging.getLogger(name)
+logger.setLevel(logging.DEBUG)
+
+
+def _launch_shell(*, cwd: Optional[pathlib.Path] = None) -> None:
+"""Launch a user shell for debugging environment.
+
+:param cwd: Working directory to start user in.
+"""
+emit.progress("Launching shell on build environment...", permanent=True)
+with emit.pause():
+subprocess.run(["bash"], check=False, cwd=cwd)
+
+
+_configure_logger("craft_providers")
+
+
+_basic_commands = [
+CleanCommand,
+RunCommand,
+RunOneCommand,
+VersionCommand,
+]
+_launchpad_commands = [
+ReleaseCommand,
+]
+
+
+def main(argv: Optional[List[str]] = None) -> int:
+"""`lpcraft` runs Launchpad CI jobs."""
+if argv is None:
+argv = sys.argv[1:]
+debug_shell = False
+emit.init(EmitterMode.BRIEF, "lpcraft", f"Starting {lpcraft_version}")
+command_groups = [
+CommandGroup("Basic", _basic_commands),
+CommandGroup("Launchpad", _launchpad_commands),
+]
+summary = "Run Launchpad CI jobs."
+extra_global_args = [
+GlobalArgument(
+"version",
+"flag",
+"-V",
+"--version",
+"Show version information and exit",
+),
+GlobalArgument(
+"debugshell",
+"flag",
+"-ds",
+"--debug-shell",
+"Shell into the environment if the build fails",
+),
+]
+
+# dispatcher = Dispatcher(
+# "lpcraft",
+# command_groups,
+# summary=summary,
+# extra_global_args=extra_global_args,
+# default_command=RunCommand,
+# )
+# global_args = dispatcher.pre_parse_args(argv)
+# if global_args["version"]:
+# emi

[Launchpad-reviewers] [Merge] ~pelpsi/lp-signing/+git/dependencies:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into ~launchpad/lp-signing/+git/dependencies:master

2023-04-12 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/lp-signing/+git/dependencies:gunicorn-upgrade-HTTP-request-smuggling-vulnerability
 into ~launchpad/lp-signing/+git/dependencies:master.

Commit message:
Added talisker dependencies

Added talisker dependencies to fix build issue.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/lp-signing/+git/dependencies/+merge/440845
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lp-signing/+git/dependencies:gunicorn-upgrade-HTTP-request-smuggling-vulnerability
 into ~launchpad/lp-signing/+git/dependencies:master.
diff --git a/contextvars-2.4.tar.gz b/contextvars-2.4.tar.gz
new file mode 100644
index 000..8a0af79
Binary files /dev/null and b/contextvars-2.4.tar.gz differ
diff --git a/immutables-0.19.tar.gz b/immutables-0.19.tar.gz
new file mode 100644
index 000..b517f28
Binary files /dev/null and b/immutables-0.19.tar.gz differ
diff --git a/typing_extensions-3.7.4.3.tar.gz b/typing_extensions-3.7.4.3.tar.gz
new file mode 100644
index 000..361a5db
Binary files /dev/null and b/typing_extensions-3.7.4.3.tar.gz differ
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:remove-old-URL-from-documentation into launchpad:master

2023-04-11 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/launchpad:remove-old-URL-from-documentation into launchpad:master.

Commit message:
Removed outdated URL from documentation

Removed outdated URL from documentation no longer working.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/440753
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:remove-old-URL-from-documentation into launchpad:master.
diff --git a/lib/lp/app/doc/displaying-paragraphs-of-text.rst b/lib/lp/app/doc/displaying-paragraphs-of-text.rst
index 3cf2c14..58b7ada 100644
--- a/lib/lp/app/doc/displaying-paragraphs-of-text.rst
+++ b/lib/lp/app/doc/displaying-paragraphs-of-text.rst
@@ -1,8 +1,7 @@
 Displaying Paragraphs of Text with ZPT
 ==
 
-To display paragraphs of text in HTML, use fmt:text-to-html. For details,
-see <https://launchpad.canonical.com/DisplayingParagraphsOfText>.
+To display paragraphs of text in HTML, use fmt:text-to-html.
 
 
 Basics
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/launchpad:duplicate_ci_jobs into launchpad:master

2023-04-06 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/launchpad:duplicate_ci_jobs into 
launchpad:master.

Commit message:
Stages now depend on series

Stages now is a dictionary where each key corresponds
to the series and the value is the old stages array.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/440534
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/launchpad:duplicate_ci_jobs into launchpad:master.
diff --git a/lib/lp/code/model/cibuild.py b/lib/lp/code/model/cibuild.py
index 23cb47a..3bd927d 100644
--- a/lib/lp/code/model/cibuild.py
+++ b/lib/lp/code/model/cibuild.py
@@ -85,17 +85,18 @@ from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
 
 def get_stages(configuration):
 """Extract the job stages for this configuration."""
-stages = []
+stages = {}
 if not configuration.pipeline:
 raise CannotBuild("No pipeline stages defined")
 for stage in configuration.pipeline:
-jobs = []
 for job_name in stage:
 if job_name not in configuration.jobs:
 raise CannotBuild("No job definition for %r" % job_name)
 for i in range(len(configuration.jobs[job_name])):
-jobs.append((job_name, i))
-stages.append(jobs)
+series = configuration.jobs[job_name][i]["series"]
+if series not in stages:
+stages[series] = []
+stages[series].append([(job_name, i)])
 return stages
 
 
@@ -750,13 +751,14 @@ class CIBuildSet(SpecificBuildFarmJobSourceMixin):
 e,
 )
 continue
+# issue would be around here
 for das in determine_DASes_to_build(configuration, logger=logger):
 self._tryToRequestBuild(
 git_repository,
 commit["sha1"],
 configuration,
 das,
-stages,
+stages[das.distroseries.name],
 logger,
 )
 
diff --git a/lib/lp/code/model/tests/test_cibuild.py b/lib/lp/code/model/tests/test_cibuild.py
index 722ecb2..c6cf309 100644
--- a/lib/lp/code/model/tests/test_cibuild.py
+++ b/lib/lp/code/model/tests/test_cibuild.py
@@ -853,9 +853,7 @@ class TestCIBuildSet(TestCaseWithFactory):
 self.assertEqual(ref.commit_sha1, build.commit_sha1)
 self.assertEqual("focal", build.distro_arch_series.distroseries.name)
 self.assertEqual("amd64", build.distro_arch_series.architecturetag)
-self.assertEqual(
-[[("build", 0), ("build", 1)], [("test", 0)]], build.stages
-)
+self.assertEqual([[("build", 1)], [("test", 0)]], build.stages)
 self.assertThat(
 reports,
 MatchesSetwise(
@@ -867,11 +865,59 @@ class TestCIBuildSet(TestCaseWithFactory):
 commit_sha1=ref.commit_sha1,
 ci_build=build,
 )
-for title in ("build:0", "build:1", "test:0")
+for title in ("build:1", "test:0")
 )
 ),
 )
 
+def test_requestBuildsForRefs_creates_correct_amount_of_builds(self):
+ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
+focal = self.factory.makeDistroSeries(
+distribution=ubuntu,
+name="focal",
+)
+jammy = self.factory.makeDistroSeries(
+distribution=ubuntu,
+name="jammy",
+)
+for series in [focal, jammy]:
+self.factory.makeBuildableDistroArchSeries(
+distroseries=series, architecturetag="amd64"
+)
+configuration = dedent(
+"""\
+pipeline:
+- build
+- test
+
+jobs:
+build:
+series: jammy
+architectures: amd64
+run: echo jammy
+test:
+series: focal
+architectures: amd64
+run: echo focal
+"""
+).encode()
+repository = self.factory.makeGitRepository()
+ref_paths = ["refs/heads/master"]
+[ref] = self.factory.makeGitRefs(repository, ref_paths)
+encoded_commit_json = {
+"sha1": ref.commit_sha1,
+"blobs": {".launchpad.yaml": configuration},
+}
+self.useFixture(GitHostingFixture(c

[Launchpad-reviewers] [Merge] ~pelpsi/lpcraft:release-0.0.52 into lpcraft:main

2023-04-06 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/lpcraft:release-0.0.52 into 
lpcraft:main.

Commit message:
New lpcraft release 0.0.52

Fix regression from adding support to snap keys
passed as strings. For these keys confinement classic
must be True by default to ensure backward compatibility.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/lpcraft/+git/lpcraft/+merge/440507
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lpcraft:release-0.0.52 into lpcraft:main.
diff --git a/NEWS.rst b/NEWS.rst
index 7ce8031..a422ffe 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -2,7 +2,7 @@
 Version history
 ===
 
-0.0.52 (Unreleased)
+0.0.52 (2023-04-06)
 ===
 - Fix regression from adding support to snap keys
   passed as strings. For these keys confinement classic
diff --git a/setup.cfg b/setup.cfg
index 8d9aa0f..2045068 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [metadata]
 name = lpcraft
-version = 0.0.51
+version = 0.0.52
 description = Runner for Launchpad CI jobs
 long_description = file: README.rst
 long_description_content_type = text/x-rst
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/lpcraft:backward-compatibility into lpcraft:main

2023-04-06 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/lpcraft:backward-compatibility into 
lpcraft:main.

Commit message:
Forced classic to True if snaps are configured as string

If snaps are configured as string the classic confinment is forced
to improve backward compatibility

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/lpcraft/+git/lpcraft/+merge/440492
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lpcraft:backward-compatibility into lpcraft:main.
diff --git a/lpcraft/commands/tests/test_run.py b/lpcraft/commands/tests/test_run.py
index 361661c..b1fc6c2 100644
--- a/lpcraft/commands/tests/test_run.py
+++ b/lpcraft/commands/tests/test_run.py
@@ -2103,6 +2103,7 @@ class TestRun(RunBaseTestCase):
 "chromium",
 "--channel",
 "latest/stable",
+"--classic",
 ],
 check=True,
 capture_output=True,
@@ -2125,6 +2126,7 @@ class TestRun(RunBaseTestCase):
 "firefox",
 "--channel",
 "latest/stable",
+"--classic",
 ],
 check=True,
 capture_output=True,
@@ -2259,6 +2261,7 @@ class TestRun(RunBaseTestCase):
 "firefox",
 "--channel",
 "latest/stable",
+"--classic",
 ],
 check=True,
 capture_output=True,
diff --git a/lpcraft/config.py b/lpcraft/config.py
index 0fdb9b4..4590cce 100644
--- a/lpcraft/config.py
+++ b/lpcraft/config.py
@@ -8,6 +8,7 @@ from pathlib import Path
 from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union
 
 import pydantic
+from craft_cli import emit
 from pydantic import AnyHttpUrl, StrictStr, root_validator, validator
 
 from lpcraft.errors import ConfigurationError
@@ -304,7 +305,13 @@ class Job(ModelConfigDefaults):
 for value in v:
 # Backward compatibility, i.e. [chromium, firefox]
 if type(value) is str:
-clean_values.append({"name": value})
+emit.message(
+f"Warning: You configured snap `{value}` but "
++ "you used a deprecated format. "
++ "Please refer to the documentation for an "
++ "overview of supported formats.",
+)
+clean_values.append({"name": value, "classic": True})
 elif type(value) is dict:
 if "name" not in value or value["name"] is None:
 raise ValueError(
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/lp-signing/+git/dependencies:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into ~launchpad/lp-signing/+git/dependencies:master

2023-04-05 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/lp-signing/+git/dependencies:gunicorn-upgrade-HTTP-request-smuggling-vulnerability
 into ~launchpad/lp-signing/+git/dependencies:master.

Commit message:
Upgraded talisker to maximize compatibility with gunicorn

A penetration test found that our gunicorn version is vulnerable, version 
20.1.0 should be safe.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/lp-signing/+git/dependencies/+merge/440423
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lp-signing/+git/dependencies:gunicorn-upgrade-HTTP-request-smuggling-vulnerability
 into ~launchpad/lp-signing/+git/dependencies:master.
diff --git a/talisker-0.20.0.tar.gz b/talisker-0.20.0.tar.gz
new file mode 100644
index 000..fe22479
Binary files /dev/null and b/talisker-0.20.0.tar.gz differ
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/lpcraft:release-0.0.51 into lpcraft:main

2023-04-05 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/lpcraft:release-0.0.51 into 
lpcraft:main.

Commit message:
New lpcraft release 0.0.51

Add support for snap's channel and confinement level.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/lpcraft/+git/lpcraft/+merge/440410
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lpcraft:release-0.0.51 into lpcraft:main.
diff --git a/setup.cfg b/setup.cfg
index 8f5eeed..8d9aa0f 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [metadata]
 name = lpcraft
-version = 0.0.50
+version = 0.0.51
 description = Runner for Launchpad CI jobs
 long_description = file: README.rst
 long_description_content_type = text/x-rst
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/rutabaga:update-rutabaga-readme into rutabaga:master

2023-04-04 Thread Simone Pelosi
Simone Pelosi has proposed merging ~pelpsi/rutabaga:update-rutabaga-readme into 
rutabaga:master.

Commit message:
Updated rutabaga README

Updated rutabaga README to be in line with Makefile

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/rutabaga/+git/rutabaga/+merge/440314
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/rutabaga:update-rutabaga-readme into rutabaga:master.
diff --git a/README.rst b/README.rst
index a5118a3..c021b1c 100644
--- a/README.rst
+++ b/README.rst
@@ -7,15 +7,22 @@ Development
 ---
 
 Install::
-
+  
+  python3 -m venv env
+  source env/bin/activate
+  pip install virtualenv
+  sudo apt install sqlite3
   pip install -r bootstrap-requirements.txt -r requirements.txt
   python3 ./setup.py develop
 
 Run::
 
   make migrate
-  make run
+  make run-api
+
+Run tests::
 
+  make check
 
 Squid3
 --
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/turnip:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into turnip:master

2023-04-04 Thread Simone Pelosi
The proposal to merge 
~pelpsi/turnip:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into 
turnip:master has been updated.

Status: Needs review => Approved

For more details, see:
https://code.launchpad.net/~pelpsi/turnip/+git/turnip/+merge/440169
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/turnip:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into 
turnip:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/turnip:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into turnip:master

2023-04-04 Thread Simone Pelosi
The proposal to merge 
~pelpsi/turnip:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into 
turnip:master has been updated.

Status: Approved => Needs review

For more details, see:
https://code.launchpad.net/~pelpsi/turnip/+git/turnip/+merge/440169
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/turnip:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into 
turnip:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/turnip:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into turnip:master

2023-04-04 Thread Simone Pelosi
The proposal to merge 
~pelpsi/turnip:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into 
turnip:master has been updated.

Status: Needs review => Approved

For more details, see:
https://code.launchpad.net/~pelpsi/turnip/+git/turnip/+merge/440169
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/turnip:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into 
turnip:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/lpcraft:snaps-key-improved-to-specify-channel-and-classic-parameters into lpcraft:main

2023-03-31 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/lpcraft:snaps-key-improved-to-specify-channel-and-classic-parameters 
into lpcraft:main.

Commit message:
Added support for channel and classic parameters

Snap keys now support channel and classic parameters.
Snap key new syntax ::

LP: #1995101


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1995101 in lpcraft: "snaps key doesn't allow to specify which channel to 
use for a snap"
  https://bugs.launchpad.net/lpcraft/+bug/1995101

For more details, see:
https://code.launchpad.net/~pelpsi/lpcraft/+git/lpcraft/+merge/440175
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/lpcraft:snaps-key-improved-to-specify-channel-and-classic-parameters 
into lpcraft:main.
diff --git a/docs/configuration.rst b/docs/configuration.rst
index d25c96d..549d6d6 100644
--- a/docs/configuration.rst
+++ b/docs/configuration.rst
@@ -63,6 +63,13 @@ Job definitions
 
 ``snaps`` (optional)
 Snaps to install as dependencies of this job.
+Snap syntax ::
+Example:
+.. code:: yaml
+snaps:
+- black:22/stable:classic
+- vim
+- firefox::classic
 
 ``environment`` (optional)
 A mapping of environment variable names to values, to be set while
diff --git a/lpcraft/commands/run.py b/lpcraft/commands/run.py
index c0e00d9..26a2071 100644
--- a/lpcraft/commands/run.py
+++ b/lpcraft/commands/run.py
@@ -543,12 +543,27 @@ def _run_job(
 ) as instance:
 snaps = list(itertools.chain(*pm.hook.lpcraft_install_snaps()))
 for snap in snaps:
-emit.progress(f"Running `snap install {snap}`")
+snap_unpacked = snap.split(":")
+snap = snap_unpacked[0]
+channel = (
+snap_unpacked[1]
+if len(snap_unpacked) > 1 and snap_unpacked[1].strip() != ""
+else "latest/stable"
+)
+classic = (
+snap_unpacked[2] == "classic"
+if len(snap_unpacked) > 2
+else False
+)
+classic_string = "classic" if classic else ""
+emit.progress(
+f"Running `snap install {snap} {channel} {classic_string}`"
+)
 install_from_store(
 executor=instance,
 snap_name=snap,
-channel="latest/stable",
-classic=True,
+channel=channel,
+classic=classic,
 )
 packages = list(itertools.chain(*pm.hook.lpcraft_install_packages()))
 if packages:
diff --git a/lpcraft/commands/tests/test_run.py b/lpcraft/commands/tests/test_run.py
index 4466295..f6ab514 100644
--- a/lpcraft/commands/tests/test_run.py
+++ b/lpcraft/commands/tests/test_run.py
@@ -1985,7 +1985,7 @@ class TestRun(RunBaseTestCase):
 series: focal
 architectures: amd64
 run: tox
-snaps: [chromium, firefox]
+snaps: [chromium::classic, firefox::classic]
 """
 )
 Path(".launchpad.yaml").write_text(config)
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/turnip:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into turnip:master

2023-03-31 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/turnip:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into 
turnip:master.

Commit message:
Upgraded gunicorn to fix HTTP request smuggling vulnerability

A penetration test found that our gunicorn version is vulnerable, version 
20.1.0 should be safe.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/turnip/+git/turnip/+merge/440169
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/turnip:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into 
turnip:master.
diff --git a/requirements.txt b/requirements.txt
index 8d5734d..c9bc202 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -22,7 +22,7 @@ future==0.18.2
 gevent==20.6.2
 gmpy==1.17
 greenlet==0.4.16
-gunicorn==19.3.0
+gunicorn==20.1.0
 hyperlink==19.0.0
 idna==2.9
 importlib_metadata==1.7.0
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~pelpsi/rutabaga/+git/dependencies:gunicorn-upgrade-HTTP-request-smuggling-vulnerability into ~canonical-launchpad-branches/rutabaga/+git/dependencies:master

2023-03-31 Thread Simone Pelosi
Simone Pelosi has proposed merging 
~pelpsi/rutabaga/+git/dependencies:gunicorn-upgrade-HTTP-request-smuggling-vulnerability
 into ~canonical-launchpad-branches/rutabaga/+git/dependencies:master.

Commit message:
Upgraded gunicorn to fix HTTP request smuggling vulnerability

A penetration test found that our gunicorn version is vulnerable, version 
20.1.0 should be safe.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pelpsi/rutabaga/+git/dependencies/+merge/440166
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~pelpsi/rutabaga/+git/dependencies:gunicorn-upgrade-HTTP-request-smuggling-vulnerability
 into ~canonical-launchpad-branches/rutabaga/+git/dependencies:master.
diff --git a/gunicorn-20.1.0.tar.gz b/gunicorn-20.1.0.tar.gz
new file mode 100644
index 000..b5da493
Binary files /dev/null and b/gunicorn-20.1.0.tar.gz differ
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


  1   2   >