diff --git a/endpoints/verbs/__init__.py b/endpoints/verbs/__init__.py index 499c9d998..449f56757 100644 --- a/endpoints/verbs/__init__.py +++ b/endpoints/verbs/__init__.py @@ -109,7 +109,15 @@ def _write_derived_image_to_storage(verb, derived_image, queue_file): # Re-Initialize the storage engine because some may not respond well to forking (e.g. S3) store = Storage(app, metric_queue, config_provider=config_provider, ip_resolver=ip_resolver) - store.stream_write(derived_image.blob.placements, derived_image.blob.storage_path, queue_file) + + try: + store.stream_write(derived_image.blob.placements, derived_image.blob.storage_path, queue_file) + except IOError as ex: + logger.debug('Exception when writing %s derived image %s: %s', verb, derived_image, ex) + + with database.UseThenDisconnect(app.config): + registry_model.delete_derived_image(derived_image) + queue_file.close()