[Launchpad-reviewers] [Merge] lp:~cjwatson/launchpad/empty-build-artifacts into lp:launchpad

2019-08-29 Thread noreply
The proposal to merge lp:~cjwatson/launchpad/empty-build-artifacts into 
lp:launchpad has been updated.

Status: Needs review => Merged

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/empty-build-artifacts/+merge/371975
-- 
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] lp:~cjwatson/launchpad/empty-build-artifacts into lp:launchpad

2019-08-28 Thread William Grant
Review: Approve code


-- 
https://code.launchpad.net/~cjwatson/launchpad/empty-build-artifacts/+merge/371975
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] lp:~cjwatson/launchpad/empty-build-artifacts into lp:launchpad

2019-08-28 Thread Colin Watson
Colin Watson has proposed merging lp:~cjwatson/launchpad/empty-build-artifacts 
into lp:launchpad.

Commit message:
Handle empty artifacts in livefs builds.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1841878 in Launchpad itself: "livefs builds fail when they produce an 
empty artifact"
  https://bugs.launchpad.net/launchpad/+bug/1841878

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/empty-build-artifacts/+merge/371975

I also considered changing launchpad-buildd to avoid sending empty artifacts, 
but it seemed a bit arbitrary, and I think it makes sense for Launchpad to be 
more robust against this anyway.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~cjwatson/launchpad/empty-build-artifacts into lp:launchpad.
=== modified file 'lib/lp/archiveuploader/livefsupload.py'
--- lib/lp/archiveuploader/livefsupload.py	2018-05-06 08:52:34 +
+++ lib/lp/archiveuploader/livefsupload.py	2019-08-29 04:14:54 +
@@ -1,4 +1,4 @@
-# Copyright 2014-2018 Canonical Ltd.  This software is licensed under the
+# Copyright 2014-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Process a live filesystem upload."""
@@ -47,7 +47,7 @@
 livefs_file, os.stat(livefs_path).st_size,
 open(livefs_path, "rb"),
 filenameToContentType(livefs_path),
-restricted=build.is_private)
+restricted=build.is_private, allow_zero_length=True)
 build.addFile(libraryfile)
 
 # The master verifies the status to confirm successful upload.

=== modified file 'lib/lp/archiveuploader/tests/test_livefsupload.py'
--- lib/lp/archiveuploader/tests/test_livefsupload.py	2019-05-24 11:10:38 +
+++ lib/lp/archiveuploader/tests/test_livefsupload.py	2019-08-29 04:14:54 +
@@ -67,3 +67,21 @@
 "LiveFS upload failed\nGot: %s" % self.log.getLogBuffer())
 self.assertEqual(BuildStatus.FULLYBUILT, self.build.status)
 self.assertTrue(self.build.verifySuccessfulUpload())
+
+def test_empty_file(self):
+# The upload processor can cope with empty build artifacts.  (LiveFS
+# is quite a general method and can include a variety of artifacts:
+# in particular it often includes an additional log file which can
+# be empty.)
+self.assertFalse(self.build.verifySuccessfulUpload())
+upload_dir = os.path.join(
+self.incoming_folder, "test", str(self.build.id), "ubuntu")
+write_file(os.path.join(upload_dir, "livecd.magic-proxy.log"), b"")
+handler = UploadHandler.forProcessor(
+self.uploadprocessor, self.incoming_folder, "test", self.build)
+result = handler.processLiveFS(self.log)
+self.assertEqual(
+UploadStatusEnum.ACCEPTED, result,
+"LiveFS upload failed\nGot: %s" % self.log.getLogBuffer())
+self.assertEqual(BuildStatus.FULLYBUILT, self.build.status)
+self.assertTrue(self.build.verifySuccessfulUpload())

=== modified file 'lib/lp/buildmaster/interactor.py'
--- lib/lp/buildmaster/interactor.py	2019-06-19 09:50:07 +
+++ lib/lp/buildmaster/interactor.py	2019-08-29 04:14:54 +
@@ -1,4 +1,4 @@
-# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 __metaclass__ = type
@@ -62,16 +62,14 @@
 self.finished = finished
 if isinstance(file_to_write, (bytes, unicode)):
 self.filename = file_to_write
-self.file = None
+self.file = tempfile.NamedTemporaryFile(
+mode="wb", prefix=os.path.basename(self.filename) + "_",
+dir=os.path.dirname(self.filename), delete=False)
 else:
 self.filename = None
 self.file = file_to_write
 
 def dataReceived(self, data):
-if self.file is None:
-self.file = tempfile.NamedTemporaryFile(
-mode="wb", prefix=os.path.basename(self.filename) + "_",
-dir=os.path.dirname(self.filename), delete=False)
 try:
 self.file.write(data)
 except IOError:

=== modified file 'lib/lp/buildmaster/tests/mock_slaves.py'
--- lib/lp/buildmaster/tests/mock_slaves.py	2019-07-02 15:43:07 +
+++ lib/lp/buildmaster/tests/mock_slaves.py	2019-08-29 04:14:54 +
@@ -1,4 +1,4 @@
-# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Mock Build objects for tests soyuz buildd-system."""
@@ -316,18 +316,18 @@
 self.base_url, 'vmhost',