Merge lp:~wgrant/launchpad/couple-of-oopses into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 17342
Proposed branch: lp:~wgrant/launchpad/couple-of-oopses
Merge into: lp:launchpad
Diff against target: 62 lines (+12/-6)
3 files modified
lib/lp/buildmaster/model/buildfarmjobbehaviour.py (+7/-2)
lib/lp/services/librarian/model.py (+2/-4)
lib/lp/services/librarianserver/swift.py (+3/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/couple-of-oopses
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+249788@code.launchpad.net

Commit message

Don't double-upload build results when the log download fails, don't squash IntegrityErrors in LibraryFileAliasSet.create, and verify that a Swift connection is what it says it is before returning it to the librarian ConnectionPool.

Description of the change

An OOPS fix, an OOPS change and an added OOPS:

 - Bug #1422199: Minimise the risk of duplicate buildd-manager uploads
   by moving the non-transactional filesystem operations as close to
   the commit as possible. Previously the log download could time out
   and abort the transaction after the upload had already been moved
   into incoming/.

 - Bug #1422207: Stop squashing IntegrityErrors in
   LibraryFileAliasSet.create. Pre-check the filename rather than
   waiting for the database to reject it and hoping that the error
   we're catching is the right one. This will let us diagnose some odd
   process-upload failures.

 - Bug #1420046: Librarian's Swift ConnectionPool now verifies that
   anything it's given is actually a swiftclient.Connection. Hopefully
   this will give us useful tracebacks at the source of the None
   connections.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/buildmaster/model/buildfarmjobbehaviour.py'
2--- lib/lp/buildmaster/model/buildfarmjobbehaviour.py 2014-06-26 12:33:51 +0000
3+++ lib/lp/buildmaster/model/buildfarmjobbehaviour.py 2015-02-16 01:16:18 +0000
4@@ -221,19 +221,24 @@
5 % (self.build.build_cookie, self.build.title,
6 self.build.buildqueue_record.builder.name, status))
7 if status == 'OK':
8+ yield self.storeLogFromSlave()
9+ # handleSuccess will sometimes perform write operations
10+ # outside the database transaction, so a failure between
11+ # here and the commit can cause duplicated results. For
12+ # example, a BinaryPackageBuild will end up in the upload
13+ # queue twice if notify() crashes.
14 yield self.handleSuccess(slave_status, logger)
15 elif status in fail_status_map:
16 # XXX wgrant: The builder should be set long before here, but
17 # currently isn't.
18+ yield self.storeLogFromSlave()
19 self.build.updateStatus(
20 fail_status_map[status],
21 builder=self.build.buildqueue_record.builder,
22 slave_status=slave_status)
23- transaction.commit()
24 else:
25 raise BuildDaemonError(
26 "Build returned unexpected status: %r" % status)
27- yield self.storeLogFromSlave()
28 if notify:
29 self.build.notify()
30 self.build.buildqueue_record.destroySelf()
31
32=== modified file 'lib/lp/services/librarian/model.py'
33--- lib/lp/services/librarian/model.py 2014-09-01 11:44:56 +0000
34+++ lib/lp/services/librarian/model.py 2015-02-16 01:16:18 +0000
35@@ -255,11 +255,9 @@
36 client = getUtility(IRestrictedLibrarianClient)
37 else:
38 client = getUtility(ILibrarianClient)
39- try:
40- fid = client.addFile(
41- name, size, file, contentType, expires, debugID)
42- except IntegrityError:
43+ if '/' in name:
44 raise InvalidFilename("Filename cannot contain slashes.")
45+ fid = client.addFile(name, size, file, contentType, expires, debugID)
46 lfa = IMasterStore(LibraryFileAlias).find(
47 LibraryFileAlias, LibraryFileAlias.id == fid).one()
48 assert lfa is not None, "client.addFile didn't!"
49
50=== modified file 'lib/lp/services/librarianserver/swift.py'
51--- lib/lp/services/librarianserver/swift.py 2014-12-16 09:20:15 +0000
52+++ lib/lp/services/librarianserver/swift.py 2015-02-16 01:16:18 +0000
53@@ -346,6 +346,9 @@
54 exception has been raised (apart from a 404), don't trust the
55 swift_connection and throw it away.
56 '''
57+ if not isinstance(swift_connection, swiftclient.Connection):
58+ raise AssertionError(
59+ "%r is not a swiftclient Connection." % swift_connection)
60 if swift_connection not in self._pool:
61 self._pool.append(swift_connection)
62 while len(self._pool) > self.MAX_POOL_SIZE: