← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~thumper/launchpad/fix-upgrade-branch-failure into lp:launchpad/devel

 

Tim Penhey has proposed merging lp:~thumper/launchpad/fix-upgrade-branch-failure into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #610401 Upgrade Branch job needs write privileges to Job
  https://bugs.launchpad.net/bugs/610401


Recently the upgrade job code was updated to use the branchChanged method call rather than requestMirror.

This works in all cases, except where someone pushes a new revision to the branch while the upgrade is happening.  If this happens, a scan job will be created as part of the branchChanged call.  This then results in a new job and branchjob row, so we need to add insert permissions for those two tables.
-- 
https://code.launchpad.net/~thumper/launchpad/fix-upgrade-branch-failure/+merge/31114
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~thumper/launchpad/fix-upgrade-branch-failure into lp:launchpad/devel.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg	2010-07-27 05:04:59 +0000
+++ database/schema/security.cfg	2010-07-28 03:17:48 +0000
@@ -1707,8 +1707,8 @@
 type=user
 groups=script
 public.branch                           = SELECT, UPDATE
-public.branchjob                        = SELECT
-public.job                              = SELECT, UPDATE
+public.branchjob                        = SELECT, INSERT
+public.job                              = SELECT, INSERT, UPDATE
 
 [send-branch-mail]
 type=user

=== modified file 'lib/lp/code/model/tests/test_branchjob.py'
--- lib/lp/code/model/tests/test_branchjob.py	2010-06-11 03:52:02 +0000
+++ lib/lp/code/model/tests/test_branchjob.py	2010-07-28 03:17:48 +0000
@@ -20,6 +20,7 @@
 from bzrlib.transport import get_transport
 from canonical.testing import DatabaseFunctionalLayer, LaunchpadZopelessLayer
 from sqlobject import SQLObjectNotFound
+from storm.locals import Store
 import transaction
 from zope.component import getUtility
 from zope.security.proxy import removeSecurityProxy
@@ -258,6 +259,7 @@
             'Bazaar-NG Knit Repository Format 1')
 
         job = BranchUpgradeJob.create(db_branch)
+        self.becomeDbUser(config.upgrade_branches.dbuser)
         job.run()
         new_branch = Branch.open(tree.branch.base)
         self.assertEqual(
@@ -289,6 +291,7 @@
             source_branch_transport.clone('backup.bzr'))
 
         job = BranchUpgradeJob.create(db_branch)
+        self.becomeDbUser(config.upgrade_branches.dbuser)
         job.run()
 
         new_branch = Branch.open(tree.branch.base)
@@ -297,6 +300,16 @@
             'Bazaar repository format 2a (needs bzr 1.16 or later)\n')
 
 
+    def test_db_user_can_request_scan(self):
+        # The database user that does the upgrade needs to be able to request
+        # a scan of the branch.
+        branch = self.factory.makeAnyBranch()
+        self.becomeDbUser(config.upgrade_branches.dbuser)
+        # Scan jobs are created by the branchChanged method.
+        branch.branchChanged('', 'new-id', None, None, None)
+        Store.of(branch).flush()
+
+
 class TestRevisionMailJob(TestCaseWithFactory):
     """Tests for BranchDiffJob."""