[Launchpad-reviewers] [Merge] ~cjwatson/launchpad:charm-appserver-rolling-restart into launchpad:master

2023-04-04 Thread Colin Watson
Colin Watson has proposed merging 
~cjwatson/launchpad:charm-appserver-rolling-restart into launchpad:master.

Commit message:
charm: Use rolling restart for launchpad-appserver

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/440349

As long as we have more than one appserver unit, this ensures that the 
application remains responsive during upgrades, using the coordinator layer to 
deal with communication between units.

With gunicorn >= 20.0, waiting for the application to be responsive on each 
unit turns out to be a matter of setting `preload_app = True` (which causes the 
application to be loaded before the arbiter signals readiness, and also saves a 
fair amount of memory) and using `Type=notify` in the systemd service.  I 
dropped the old soft-restart mechanism when only `*-lazr.conf` files are 
changed, since it doesn't quite work with application preloading and it wasn't 
all that much of a win anyway.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~cjwatson/launchpad:charm-appserver-rolling-restart into launchpad:master.
diff --git a/charm/launchpad-appserver/charmcraft.yaml b/charm/launchpad-appserver/charmcraft.yaml
index b35779b..613dc0b 100644
--- a/charm/launchpad-appserver/charmcraft.yaml
+++ b/charm/launchpad-appserver/charmcraft.yaml
@@ -45,10 +45,23 @@ parts:
   - layers
 prime:
   - "-layers"
+  layer-coordinator:
+source: https://git.launchpad.net/layer-coordinator
+source-commit: "fa27fc93e0b08000963e83a6bfe49812d890dfcf"
+source-submodules: []
+source-type: git
+plugin: dump
+organize:
+  "*": layers/layer/coordinator/
+stage:
+  - layers
+prime:
+  - "-layers"
   launchpad-appserver:
 after:
   - charm-wheels
   - launchpad-layers
+  - layer-coordinator
 source: .
 plugin: reactive
 build-snaps: [charm/2.x/stable]
diff --git a/charm/launchpad-appserver/layer.yaml b/charm/launchpad-appserver/layer.yaml
index dae6f8a..87a5643 100644
--- a/charm/launchpad-appserver/layer.yaml
+++ b/charm/launchpad-appserver/layer.yaml
@@ -1,5 +1,6 @@
 includes:
   - layer:launchpad-base
+  - layer:coordinator
   - interface:memcache
 repo: https://git.launchpad.net/launchpad
 options:
diff --git a/charm/launchpad-appserver/reactive/launchpad-appserver.py b/charm/launchpad-appserver/reactive/launchpad-appserver.py
index 99ef7f6..1c32282 100644
--- a/charm/launchpad-appserver/reactive/launchpad-appserver.py
+++ b/charm/launchpad-appserver/reactive/launchpad-appserver.py
@@ -6,6 +6,7 @@ import subprocess
 from multiprocessing import cpu_count
 
 from charmhelpers.core import hookenv, host, templating
+from charms.coordinator import acquire
 from charms.launchpad.base import (
 config_file_path,
 configure_cron,
@@ -24,6 +25,7 @@ from charms.reactive import (
 set_flag,
 set_state,
 when,
+when_none,
 when_not,
 )
 from ols import base, postgres
@@ -64,6 +66,7 @@ def configure_gunicorn(config):
 templating.render(
 "launchpad.service.j2", "/lib/systemd/system/launchpad.service", config
 )
+subprocess.run(["systemctl", "daemon-reload"], check=True)
 host.add_user_to_group("syslog", base.user())
 templating.render("rsyslog.j2", "/etc/rsyslog.d/22-launchpad.conf", config)
 
@@ -78,13 +81,6 @@ def configure_logrotate(config):
 )
 
 
-def restart(soft=False):
-if soft:
-reload_or_restart("launchpad")
-else:
-host.service_restart("launchpad")
-
-
 def config_files():
 files = []
 files.extend(lazr_config_files())
@@ -100,7 +96,7 @@ def config_files():
 "session-db.master.available",
 "memcache.available",
 )
-@when_not("service.configured")
+@when_none("coordinator.requested.restart", "service.configured")
 def configure():
 session_db = endpoint_from_flag("session-db.master.available")
 memcache = endpoint_from_flag("memcache.available")
@@ -133,19 +129,21 @@ def configure():
 configure_logrotate(config)
 configure_cron(config, "crontab.j2")
 
-restart_type = None
 if helpers.any_file_changed(
 [base.version_info_path(), "/lib/systemd/system/launchpad.service"]
++ config_files()
 ):
-restart_type = "hard"
-elif helpers.any_file_changed(config_files()):
-restart_type = "soft"
-if restart_type is None:
-hookenv.log("Not restarting, since no config files were changed")
+hookenv.log("Config files changed; waiting for restart lock")
+acquire("restart")
 else:
-hookenv.log(f"Config files changed; performing {restart_type} restart")
-restart(soft=(restart_type == "soft"))
+hookenv.log("Not restarting, since no config files were changed")
+set_state("service.configured")
+
 
+@when("coordinator.granted.restart")
+def restart():
+hookenv.log("Restarting applica

[Launchpad-reviewers] [Merge] ~ines-almeida/launchpad:prevent-bug-reporter-from-accessing-bug-in-disabled-product into launchpad:master

2023-04-04 Thread Ines Almeida
Ines Almeida has proposed merging 
~ines-almeida/launchpad:prevent-bug-reporter-from-accessing-bug-in-disabled-product
 into launchpad:master.

Commit message:
Exclude bugs from inactive product series in queries

Update query to exclude BugTasks from inactive product series from a user's 
reported bugs list

LP: #1321055

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1321055 in Launchpad itself: "Deactivating a product doesn't hide its 
productseries' bugs"
  https://bugs.launchpad.net/launchpad/+bug/1321055

For more details, see:
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/440317

Update a query and introduced 2 unit tests that verify the change:
 - one that ensures the user can't see the bug they reported on an inactive 
product (which passed before and after the change)
 - one that ensures the user can't see the bug they reported on an inactive 
product *series* (which failed before the change)
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ines-almeida/launchpad:prevent-bug-reporter-from-accessing-bug-in-disabled-product
 into launchpad:master.
diff --git a/lib/lp/bugs/model/bugtasksearch.py b/lib/lp/bugs/model/bugtasksearch.py
index 19598bc..1cebcef 100644
--- a/lib/lp/bugs/model/bugtasksearch.py
+++ b/lib/lp/bugs/model/bugtasksearch.py
@@ -72,7 +72,7 @@ from lp.registry.model.distribution import Distribution
 from lp.registry.model.milestone import Milestone
 from lp.registry.model.milestonetag import MilestoneTag
 from lp.registry.model.person import Person
-from lp.registry.model.product import Product, ProductSet
+from lp.registry.model.product import Product, ProductSeries, ProductSet
 from lp.registry.model.teammembership import TeamParticipation
 from lp.services.database.bulk import load
 from lp.services.database.decoratedresultset import DecoratedResultSet
@@ -84,6 +84,7 @@ from lp.services.database.sqlbase import (
 from lp.services.database.stormexpr import (
 ArrayAgg,
 ArrayIntersects,
+IsTrue,
 Unnest,
 WithMaterialized,
 fti_search,
@@ -609,15 +610,30 @@ def _build_query(params):
 and params.productseries is None
 and params.distroseries is None
 ):
-extra_clauses.append(
-Or(BugTaskFlat.product == None, Product.active == True)
+extra_clauses.append(IsTrue(Product.active))
+
+join_tables.append(
+(
+ProductSeries,
+LeftJoin(
+ProductSeries,
+BugTaskFlat.productseries_id == ProductSeries.id,
+),
+)
 )
+
 join_tables.append(
 (
 Product,
 LeftJoin(
 Product,
-And(BugTaskFlat.product_id == Product.id, Product.active),
+And(
+Or(
+BugTaskFlat.product_id == Product.id,
+ProductSeries.productID == Product.id,
+),
+Product.active,
+),
 ),
 )
 )
diff --git a/lib/lp/registry/tests/test_private_team_visibility.py b/lib/lp/registry/tests/test_private_team_visibility.py
index 6f68e2f..1a7bdab 100644
--- a/lib/lp/registry/tests/test_private_team_visibility.py
+++ b/lib/lp/registry/tests/test_private_team_visibility.py
@@ -24,6 +24,7 @@ from lp.registry.interfaces.teammembership import (
 ITeamMembershipSet,
 TeamMembershipStatus,
 )
+from lp.services.propertycache import clear_property_cache
 from lp.services.webapp.authorization import (
 check_permission,
 clear_cache,
@@ -33,6 +34,7 @@ from lp.services.webapp.interaction import ANONYMOUS
 from lp.services.webapp.servers import LaunchpadTestRequest
 from lp.testing import (
 TestCaseWithFactory,
+admin_logged_in,
 login,
 login_celebrity,
 login_person,
@@ -412,3 +414,45 @@ class TestPrivateTeamVisibility(TestCaseWithFactory):
 
 def test_team_assigned_to_private_bug(self):
 self._test_team_assigned_to_bug()
+
+def test_user_cant_see_bug_disabled_product(self, product_series=False):
+"""A user that reports a bug in a private project, can't see the bug
+once the project is deactivated
+"""
+private_product = self.factory.makeProduct(
+owner=self.priv_team,
+information_type=InformationType.PROPRIETARY,
+registrant=self.priv_owner,
+)
+if product_series:
+private_series = self.factory.makeProductSeries(
+product=private_product
+)
+# Report a bug within the private product
+login_person(self.priv_member)
+bug = self.factory.makeBug(
+owner=self.priv_member, target=private_product
+)
+
+# Change target to the product series
+   

[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 Otto Co-Pilot
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


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

2023-04-04 Thread Otto Co-Pilot
Voting criteria not met
https://jenkins.ols.canonical.com/online-services/job/turnip/401/
-- 
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/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


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

2023-04-04 Thread Guruprasad
LGTM 👍🏼 Please merge this after merging the corresponding dependencies MP.
-- 
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