From a423032e8079a762266f1a3eec1e12dd3c2c0de9 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 16 Oct 2014 12:54:16 -0400 Subject: [PATCH] - Make sure we log when an exception occurs in the squashing code - Have queue file always try to return any remaining data in the buffer - Remove the raise of the exception when we get an empty tar file --- endpoints/verbs.py | 1 + util/queuefile.py | 4 +++- util/tarlayerformat.py | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/endpoints/verbs.py b/endpoints/verbs.py index df50a8c39..7a808ef8e 100644 --- a/endpoints/verbs.py +++ b/endpoints/verbs.py @@ -49,6 +49,7 @@ def _write_synthetic_image_to_storage(linked_storage_uuid, linked_locations, que store = Storage(app) def handle_exception(ex): + logger.debug('Exception when building squashed image %s: %s', linked_storage_uuid, ex) model.delete_derived_storage_by_uuid(linked_storage_uuid) queue_file.add_exception_handler(handle_exception) diff --git a/util/queuefile.py b/util/queuefile.py index 81e6f318e..95615af93 100644 --- a/util/queuefile.py +++ b/util/queuefile.py @@ -20,7 +20,9 @@ class QueueFile(object): def read(self, size=8192): if self._closed or self._done: - return None + buf = self._buffer[0:size] + self._buffer = self._buffer[size:] + return buf while len(self._buffer) < size: result = self._queue.get(block=True) diff --git a/util/tarlayerformat.py b/util/tarlayerformat.py index 28d1691a2..545013277 100644 --- a/util/tarlayerformat.py +++ b/util/tarlayerformat.py @@ -13,7 +13,6 @@ class TarLayerFormat(object): try: tar_file = tarfile.open(mode='r|*', fileobj=current_tar) except tarfile.ReadError as re: - raise re continue # For each of the tar entries, yield them IF and ONLY IF we have not