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

Proposed by Tim Penhey
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 11251
Proposed branch: lp:~thumper/launchpad/fix-upgrade-branch-failure
Merge into: lp:launchpad
Diff against target: 58 lines (+14/-2)
2 files modified
database/schema/security.cfg (+2/-2)
lib/lp/code/model/tests/test_branchjob.py (+12/-0)
To merge this branch: bzr merge lp:~thumper/launchpad/fix-upgrade-branch-failure
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+31114@code.launchpad.net

Commit message

Add insert permissions for the job and branch job table so upgrade jobs can create scan jobs if needed.

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

it looks ok except on line 45 you have 2 lines of VWS, in a class only one line between methods please

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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:44:50 +0000
@@ -1707,8 +1707,8 @@
1707type=user1707type=user
1708groups=script1708groups=script
1709public.branch = SELECT, UPDATE1709public.branch = SELECT, UPDATE
1710public.branchjob = SELECT1710public.branchjob = SELECT, INSERT
1711public.job = SELECT, UPDATE1711public.job = SELECT, INSERT, UPDATE
17121712
1713[send-branch-mail]1713[send-branch-mail]
1714type=user1714type=user
17151715
=== 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:44:50 +0000
@@ -20,6 +20,7 @@
20from bzrlib.transport import get_transport20from bzrlib.transport import get_transport
21from canonical.testing import DatabaseFunctionalLayer, LaunchpadZopelessLayer21from canonical.testing import DatabaseFunctionalLayer, LaunchpadZopelessLayer
22from sqlobject import SQLObjectNotFound22from sqlobject import SQLObjectNotFound
23from storm.locals import Store
23import transaction24import transaction
24from zope.component import getUtility25from zope.component import getUtility
25from zope.security.proxy import removeSecurityProxy26from zope.security.proxy import removeSecurityProxy
@@ -258,6 +259,7 @@
258 'Bazaar-NG Knit Repository Format 1')259 'Bazaar-NG Knit Repository Format 1')
259260
260 job = BranchUpgradeJob.create(db_branch)261 job = BranchUpgradeJob.create(db_branch)
262 self.becomeDbUser(config.upgrade_branches.dbuser)
261 job.run()263 job.run()
262 new_branch = Branch.open(tree.branch.base)264 new_branch = Branch.open(tree.branch.base)
263 self.assertEqual(265 self.assertEqual(
@@ -289,6 +291,7 @@
289 source_branch_transport.clone('backup.bzr'))291 source_branch_transport.clone('backup.bzr'))
290292
291 job = BranchUpgradeJob.create(db_branch)293 job = BranchUpgradeJob.create(db_branch)
294 self.becomeDbUser(config.upgrade_branches.dbuser)
292 job.run()295 job.run()
293296
294 new_branch = Branch.open(tree.branch.base)297 new_branch = Branch.open(tree.branch.base)
@@ -296,6 +299,15 @@
296 new_branch.repository._format.get_format_string(),299 new_branch.repository._format.get_format_string(),
297 'Bazaar repository format 2a (needs bzr 1.16 or later)\n')300 'Bazaar repository format 2a (needs bzr 1.16 or later)\n')
298301
302 def test_db_user_can_request_scan(self):
303 # The database user that does the upgrade needs to be able to request
304 # a scan of the branch.
305 branch = self.factory.makeAnyBranch()
306 self.becomeDbUser(config.upgrade_branches.dbuser)
307 # Scan jobs are created by the branchChanged method.
308 branch.branchChanged('', 'new-id', None, None, None)
309 Store.of(branch).flush()
310
299311
300class TestRevisionMailJob(TestCaseWithFactory):312class TestRevisionMailJob(TestCaseWithFactory):
301 """Tests for BranchDiffJob."""313 """Tests for BranchDiffJob."""