← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:garbo-access-artifact-permissions into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:garbo-access-artifact-permissions into launchpad:master.

Commit message:
Grant garbo access to delete AccessArtifact and friends

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

If a private GitRepository failed to create and is being pruned, then it will have `AccessArtifact` and related rows.  This started happening on production recently.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:garbo-access-artifact-permissions into launchpad:master.
diff --git a/database/schema/security.cfg b/database/schema/security.cfg
index 5da2031..f708f97 100644
--- a/database/schema/security.cfg
+++ b/database/schema/security.cfg
@@ -2414,7 +2414,10 @@ type=user
 
 [garbo]
 groups=script,read
+public.accessartifact                   = SELECT, DELETE
+public.accessartifactgrant              = SELECT, DELETE
 public.accesspolicy                     = SELECT, DELETE
+public.accesspolicyartifact             = SELECT, DELETE
 public.accesspolicygrant                = SELECT, DELETE
 public.account                          = SELECT, DELETE
 public.answercontact                    = SELECT, DELETE
diff --git a/lib/lp/scripts/tests/test_garbo.py b/lib/lp/scripts/tests/test_garbo.py
index e7f7dca..ba2b5dd 100644
--- a/lib/lp/scripts/tests/test_garbo.py
+++ b/lib/lp/scripts/tests/test_garbo.py
@@ -1109,6 +1109,13 @@ class TestGarbo(FakeAdapterMixin, TestCaseWithFactory):
             repo.status = GitRepositoryStatus.CREATING
             long_ago += timedelta(seconds=1)
 
+        # Create an old stale private repository as well.
+        repo = removeSecurityProxy(self.factory.makeGitRepository(
+            information_type=InformationType.USERDATA))
+        repo.date_created = long_ago
+        repo.status = GitRepositoryStatus.CREATING
+        long_ago += timedelta(seconds=1)
+
         recent_creating, old_available, recent_available = [
             removeSecurityProxy(self.factory.makeGitRepository())
             for _ in range(3)]
@@ -1122,7 +1129,7 @@ class TestGarbo(FakeAdapterMixin, TestCaseWithFactory):
         recent_available.date_created = recently
         recent_available.status = GitRepositoryStatus.AVAILABLE
 
-        self.assertEqual(8, store.find(GitRepository).count())
+        self.assertEqual(9, store.find(GitRepository).count())
 
         self.runHourly(maximum_chunk_size=2)