Merge lp:~jelmer/launchpad/upgrade-stderr into lp:launchpad

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 13553
Proposed branch: lp:~jelmer/launchpad/upgrade-stderr
Merge into: lp:launchpad
Diff against target: 118 lines (+25/-16)
4 files modified
lib/lp/codehosting/codeimport/tests/test_uifactory.py (+10/-0)
lib/lp/codehosting/codeimport/tests/test_worker.py (+5/-7)
lib/lp/codehosting/codeimport/uifactory.py (+4/-0)
lib/lp/codehosting/codeimport/worker.py (+6/-9)
To merge this branch: bzr merge lp:~jelmer/launchpad/upgrade-stderr
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Martin Pool (community) Approve
Tim Penhey Pending
Review via email: mp+69225@code.launchpad.net

This proposal supersedes a proposal from 2011-07-20.

Commit message

[r=jcsackett,mbp][bug=808035] Fix processing of code imports that are currently stored in an old bzr format.

Description of the change

Fix processing of code imports that are in an old bzr format:

 1) Implement show_user_warning in the custom LoggingUIFactory used in the code import
    workers. This fixes the immediate issue that causes the traceback,
    and will prevent issues in the future if parts of bazaar print user warnings.

 2) Reintroduce the automatic upgrading of code imports, and fix the related test.
    Previously the test would compare the formats of the bzr dirs, both of which
    would be "Bazaar-NG meta directory, format 1". The test now compares the
    repository formats, which are different.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote : Posted in a previous version of this proposal

merge approve
vote approve

I wonder if the automatic upgrades will be safe. Perhaps you should check
with Tim or guard it with a flag, if they're available there.
On Jul 21, 2011 3:30 AM, "Jelmer Vernooij" <email address hidden> wrote:
> Jelmer Vernooij has proposed merging lp:~jelmer/launchpad/upgrade-stderr
into lp:launchpad.
>
> Requested reviews:
> Launchpad code reviewers (launchpad-reviewers)
> Related bugs:
> Bug #808035 in Launchpad itself: "AttributeError: 'NoneType' object has no
attribute 'write' during git import"
> https://bugs.launchpad.net/launchpad/+bug/808035
>
> For more details, see:
> https://code.launchpad.net/~jelmer/launchpad/upgrade-stderr/+merge/68579
>
> Fix processing of code imports that are in an old bzr format:
>
> 1) Implement show_user_warning in the custom LoggingUIFactory used in the
code import
> workers. This fixes the immediate issue that causes the traceback,
> and will prevent issues in the future if parts of bazaar print user
warnings.
>
> 2) Reintroduce the automatic upgrading of code imports, and fix the
related test.
> Previously the test would compare the formats of the bzr dirs, both of
which
> would be "Bazaar-NG meta directory, format 1". The test now compares the
> repository formats, which are different.
> --
> https://code.launchpad.net/~jelmer/launchpad/upgrade-stderr/+merge/68579
> You are subscribed to branch lp:launchpad.

Revision history for this message
j.c.sackett (jcsackett) wrote : Posted in a previous version of this proposal

I'm going to second pinging Tim to make sure this is safe; I see that the associated bug in his XXX is fix released (though its flags seem off), but I'd like to make sure we can safely throw the automatic upgrade switch before approving.

review: Needs Information
Revision history for this message
Jelmer Vernooij (jelmer) wrote : Posted in a previous version of this proposal

Hi Tim,

Since you last touched the auto upgrade code in Launchpad before me, can you perhaps review this branch? We've had some fall out from this earlier, so would like to be extra sure it's doing the right thing.

Revision history for this message
Jelmer Vernooij (jelmer) wrote : Posted in a previous version of this proposal

> I'm going to second pinging Tim to make sure this is safe; I see that the
> associated bug in his XXX is fix released (though its flags seem off), but I'd
> like to make sure we can safely throw the automatic upgrade switch before
> approving.
Thanks for the review.

The XXX bug was fixed earlier but then rolled back because of an incident ( https://wiki.canonical.com/IncidentReports/2011-06-17-LP-codeimport-upgrade-breakage)

Revision history for this message
Tim Penhey (thumper) wrote : Posted in a previous version of this proposal

The primary reason that we disabled the automatic upgrade was that there are hundreds, maybe thousands of code imports in the old format. Also upgrading to packs was a slow process. We only had so code import workers, and we didn't want to clog them all up doing upgrades.

Perhaps the best solution is to work out how to limit the number of workers on any given slave are doing upgrades.

Revision history for this message
Martin Pool (mbp) wrote : Posted in a previous version of this proposal

Perhaps we should land just the stderr fix, and then do the upgrades
asynchronously from imports?

Revision history for this message
Jelmer Vernooij (jelmer) wrote : Posted in a previous version of this proposal

Hi Tim!

Thanks for looking at this.

> The primary reason that we disabled the automatic upgrade was that there are
> hundreds, maybe thousands of code imports in the old format. Also upgrading
> to packs was a slow process. We only had so code import workers, and we
> didn't want to clog them all up doing upgrades.
>
> Perhaps the best solution is to work out how to limit the number of workers on
> any given slave are doing upgrades.
I don't think this problem is as bad as it used to be. The upgrade code in Bazaar has improved really significantly since the auto-upgrades were disabled in Launchpad, and is now quicker than the foreign plugins.

All of the branches that were enabled and in the older format have been marked as failing because of the regression (introduced around July 1) that's fixed by this MP. According to the FailingCodeImportsMetrics graph, that appears to be between 65 branches and 100 branches.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Another thing that should make the upgrade a lot quicker is that the upgrades now happen on the local copy of the workers, rather than on the vcs-imports mirror copy.

Revision history for this message
Martin Pool (mbp) wrote :

this still looks reasonable to me, though it perhaps still needs a review from ~launchpad

review: Approve
Revision history for this message
j.c.sackett (jcsackett) wrote :

Jelmer has pointed out that all the old repositories needing upgrading are disabled right now; we can land this, and enable those repositories a few at a time to avoid any issues.

Given that, I think this code looks good to land.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/codehosting/codeimport/tests/test_uifactory.py'
2--- lib/lp/codehosting/codeimport/tests/test_uifactory.py 2010-08-20 20:31:18 +0000
3+++ lib/lp/codehosting/codeimport/tests/test_uifactory.py 2011-07-26 08:48:53 +0000
4@@ -98,6 +98,16 @@
5 'hi 3/10'],
6 self.messages)
7
8+ def test_user_warning(self):
9+ factory = self.makeLoggingUIFactory()
10+ factory.show_user_warning('cross_format_fetch',
11+ from_format="athing", to_format="anotherthing")
12+ message = factory._user_warning_templates['cross_format_fetch'] % {
13+ "from_format": "athing",
14+ "to_format": "anotherthing",
15+ }
16+ self.assertEqual([message], self.messages)
17+
18
19 def test_suite():
20 return unittest.TestLoader().loadTestsFromName(__name__)
21
22=== modified file 'lib/lp/codehosting/codeimport/tests/test_worker.py'
23--- lib/lp/codehosting/codeimport/tests/test_worker.py 2011-06-21 05:38:15 +0000
24+++ lib/lp/codehosting/codeimport/tests/test_worker.py 2011-07-26 08:48:53 +0000
25@@ -24,12 +24,10 @@
26 )
27 from bzrlib.errors import (
28 NoSuchFile,
29- NotBranchError,
30 )
31 from bzrlib.tests import TestCaseWithTransport
32 from bzrlib import trace
33 from bzrlib.transport import get_transport
34-from bzrlib.upgrade import upgrade
35 from bzrlib.urlutils import (
36 join as urljoin,
37 local_path_from_url,
38@@ -210,16 +208,17 @@
39 store = self.makeBranchStore()
40 target_url = store._getMirrorURL(self.arbitrary_branch_id)
41 knit_format = format_registry.get('knit')()
42- create_branch_with_one_revision(target_url, format=knit_format)
43- default_format = BzrDirFormat.get_default_format()
44+ tree = create_branch_with_one_revision(target_url, format=knit_format)
45+ self.assertNotEquals(tree.bzrdir._format.repository_format.network_name(),
46+ default_format.repository_format.network_name())
47
48 # The fetched branch is in the default format.
49 new_branch = store.pull(
50 self.arbitrary_branch_id, self.temp_dir, default_format)
51 # Make sure backup.bzr is removed, as it interferes with CSCVS.
52 self.assertEquals(os.listdir(self.temp_dir), [".bzr"])
53- self.assertEqual(
54- default_format, new_branch.bzrdir._format)
55+ self.assertEquals(new_branch.repository._format.network_name(),
56+ default_format.repository_format.network_name())
57
58 def test_pushUpgradesFormat(self):
59 # A branch should always be in the most up-to-date format before a
60@@ -228,7 +227,6 @@
61 target_url = store._getMirrorURL(self.arbitrary_branch_id)
62 knit_format = format_registry.get('knit')()
63 create_branch_with_one_revision(target_url, format=knit_format)
64- default_format = BzrDirFormat.get_default_format()
65
66 # The fetched branch is in the default format.
67 new_branch = store.pull(
68
69=== modified file 'lib/lp/codehosting/codeimport/uifactory.py'
70--- lib/lp/codehosting/codeimport/uifactory.py 2010-08-20 20:31:18 +0000
71+++ lib/lp/codehosting/codeimport/uifactory.py 2011-07-26 08:48:53 +0000
72@@ -36,9 +36,13 @@
73 """
74 TextUIFactory.__init__(self)
75 self.interval = interval
76+ self.writer = writer
77 self._progress_view = LoggingTextProgressView(
78 time_source, writer, interval)
79
80+ def show_user_warning(self, warning_id, **message_args):
81+ self.writer(self.format_user_warning(warning_id, message_args))
82+
83
84 class LoggingTextProgressView(TextProgressView):
85 """Support class for `LoggingUIFactory`. """
86
87=== modified file 'lib/lp/codehosting/codeimport/worker.py'
88--- lib/lp/codehosting/codeimport/worker.py 2011-06-21 05:38:15 +0000
89+++ lib/lp/codehosting/codeimport/worker.py 2011-07-26 08:48:53 +0000
90@@ -100,15 +100,6 @@
91 if needs_tree:
92 local_branch.bzrdir.create_workingtree()
93 return local_branch
94- # XXX Tim Penhey 2009-09-18 bug 432217 Automatic upgrade of import
95- # branches disabled. Need an orderly upgrade process.
96- if False and remote_bzr_dir.needs_format_conversion(
97- format=required_format):
98- try:
99- remote_bzr_dir.root_transport.delete_tree('backup.bzr')
100- except NoSuchFile:
101- pass
102- upgrade(remote_url, required_format)
103 # The proper thing to do here would be to call
104 # "remote_bzr_dir.sprout()". But 2a fetch slowly checks which
105 # revisions are in the ancestry of the tip of the remote branch, which
106@@ -121,6 +112,12 @@
107 target_control.create_prefix()
108 remote_bzr_dir.transport.copy_tree_to_transport(target_control)
109 local_bzr_dir = BzrDir.open_from_transport(target)
110+ if local_bzr_dir.needs_format_conversion(format=required_format):
111+ try:
112+ local_bzr_dir.root_transport.delete_tree('backup.bzr')
113+ except NoSuchFile:
114+ pass
115+ upgrade(target_path, required_format, clean_up=True)
116 if needs_tree:
117 local_bzr_dir.create_workingtree()
118 return local_bzr_dir.open_branch()