← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/drop-populate-branch-ap into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/drop-populate-branch-ap into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/drop-populate-branch-ap/+merge/111544

PopulateBranchAccessPolicy has finished on staging, qastaging, dogfood and production. It can be deleted.
-- 
https://code.launchpad.net/~stevenk/launchpad/drop-populate-branch-ap/+merge/111544
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/drop-populate-branch-ap into lp:launchpad.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg	2012-06-20 07:29:38 +0000
+++ database/schema/security.cfg	2012-06-22 05:55:33 +0000
@@ -2195,8 +2195,6 @@
 
 [garbo]
 groups=script,read
-public.accessartifact                   = SELECT, INSERT
-public.accesspolicyartifact             = SELECT, INSERT
 public.account                          = SELECT, DELETE
 public.answercontact                    = SELECT, DELETE
 public.branch                           = SELECT, UPDATE

=== modified file 'lib/lp/scripts/garbo.py'
--- lib/lp/scripts/garbo.py	2012-06-21 01:19:50 +0000
+++ lib/lp/scripts/garbo.py	2012-06-22 05:55:33 +0000
@@ -51,7 +51,6 @@
     MAX_SAMPLE_SIZE,
     )
 from lp.code.interfaces.revision import IRevisionSet
-from lp.code.model.branch import Branch
 from lp.code.model.codeimportevent import CodeImportEvent
 from lp.code.model.codeimportresult import CodeImportResult
 from lp.code.model.revision import (
@@ -59,7 +58,6 @@
     RevisionCache,
     )
 from lp.hardwaredb.model.hwdb import HWSubmission
-from lp.registry.enums import PRIVATE_INFORMATION_TYPES
 from lp.registry.model.person import Person
 from lp.services.config import config
 from lp.services.database import postgresql
@@ -1139,39 +1137,6 @@
         transaction.commit()
 
 
-class PopulateBranchAccessPolicy(TunableLoop):
-
-    maximum_chunk_size = 5000
-
-    def __init__(self, log, abort_time=None):
-        super(PopulateBranchAccessPolicy, self).__init__(log, abort_time)
-        self.memcache_key = '%s:branch-populate-ap' % config.instance_name
-        watermark = getUtility(IMemcacheClient).get(self.memcache_key)
-        self.start_at = watermark or 0
-
-    def findBranches(self):
-        return IMasterStore(Branch).find(
-            Branch,
-            Branch.information_type.is_in(PRIVATE_INFORMATION_TYPES),
-            SQL("Branch.access_policy IS NULL"),
-            Branch.id >= self.start_at).order_by(Branch.id)
-
-    def isDone(self):
-        return self.findBranches().is_empty()
-
-    def __call__(self, chunk_size):
-        for branch in self.findBranches()[:chunk_size]:
-            branch._reconcileAccess()
-            IMasterStore(Branch).execute(
-                'SELECT branch_denorm_access(?)', (branch.id,))
-            self.start_at = branch.id + 1
-        result = getUtility(IMemcacheClient).set(
-            self.memcache_key, self.start_at)
-        if not result:
-            self.log.warning('Failed to set start_at in memcache.')
-        transaction.commit()
-
-
 class BaseDatabaseGarbageCollector(LaunchpadCronScript):
     """Abstract base class to run a collection of TunableLoops."""
     script_name = None  # Script name for locking and database user. Override.
@@ -1427,7 +1392,6 @@
         DuplicateSessionPruner,
         BugHeatUpdater,
         BugTaskFlattener,
-        PopulateBranchAccessPolicy,
         ]
     experimental_tunable_loops = []
 

=== modified file 'lib/lp/scripts/tests/test_garbo.py'
--- lib/lp/scripts/tests/test_garbo.py	2012-06-19 05:22:50 +0000
+++ lib/lp/scripts/tests/test_garbo.py	2012-06-22 05:55:33 +0000
@@ -55,8 +55,6 @@
     )
 from lp.code.model.codeimportevent import CodeImportEvent
 from lp.code.model.codeimportresult import CodeImportResult
-from lp.registry.enums import InformationType
-from lp.registry.interfaces.accesspolicy import IAccessPolicyArtifactSource
 from lp.registry.interfaces.distribution import IDistributionSet
 from lp.registry.interfaces.person import IPersonSet
 from lp.scripts.garbo import (
@@ -1151,30 +1149,6 @@
         self.runHourly()
         self.assertEqual((task.id,), get_flat())
 
-    def test_PopulateBranchAccessPolicy(self):
-        # Branches without a access_policy have one set by the job.
-        with dbuser('testadmin'):
-            branch = self.factory.makeBranch()
-
-        def get_access_policy():
-            return IMasterStore(BugTask).execute(
-                'SELECT access_policy FROM branch WHERE id = ?',
-                (branch.id,)).get_one()[0]
-
-        # The branch is public, so running the garbo job will have no effect.
-        self.runHourly()
-        self.assertIs(None, get_access_policy())
-
-        with dbuser('testadmin'):
-            branch.transitionToInformationType(
-                InformationType.USERDATA, branch.owner, verify_policy=False)
-        access_artifact = self.factory.makeAccessArtifact(concrete=branch)
-        apas = getUtility(IAccessPolicyArtifactSource).findByArtifact(
-            (access_artifact,))
-        # Now it will be set.
-        self.runHourly()
-        self.assertEqual(apas[0].policy.id, get_access_policy())
-        
 
 class TestGarboTasks(TestCaseWithFactory):
     layer = LaunchpadZopelessLayer


Follow ups