deb-glance/glance
Paul Bourke 95e00c9247 Fix cache not handling backend failures
1) caching_iter doesn't handle backend exceptions:

caching_iter assumes any exception that occurs is the result of being
unable to cache.  Hence the IOError raised from size_checked_iter, which
indicates a problem with the backend, means the caching_iter will
continuing trying to serve non-existent data.  The exception was not
been re-raised in this case, making wsgi keep the connection open and
clients stuck forever waiting for more data.

Raising a GlanceException in size_checked_iter rather than an IOError
allows caching_iter to distinguish between a problem fetching data, and
a problem writing to the cache.

2) Checksum verification happens after cache commit rather than before:

This block was outside the context manager block which meant the
GlanceException was not caught by open_for_write and the rollback didn't
happen.  This resulted in an error been logged, but the bad image still
placed in and subsequently served from the cache.

Also:

* Fix test_gate_caching_iter_bad_checksum - the loop to consume the
  iterator in was in a subroutine that never got called.

* Move test_gate_caching_iter_(good|bad)_checksum into
  ImageCacheTestCase to excercise both the sql and xattr drivers.

* Remove invalid registry_host/registry_port params from
  TestImageCacheXattr/TestImageCacheSqlite setup which caused a failure
  when testing the file on it's own using nosetests.

Fixes bug 1045792

Change-Id: I8aedec347e7f50566c44c5b6c6db424573c5ebaf
2012-09-04 13:39:39 +01:00
..
api Fix cache not handling backend failures 2012-09-04 13:39:39 +01:00
common Merge "HTTPBadRequest in v2 on malformed JSON request body." 2012-08-28 23:58:31 +00:00
db Require 'status' in simple db image_create 2012-09-03 20:52:57 -07:00
image_cache Fix cache not handling backend failures 2012-09-04 13:39:39 +01:00
locale Add localization catalog and initial po files to Glance. 2012-05-04 11:24:30 +08:00
notifier fix the qpid_heartbeat option so that it's effective 2012-08-02 18:58:28 +01:00
openstack Move to tag-based versioning. 2012-08-12 16:10:03 +00:00
registry Fix LP bug #1044462 cfg items need secret=True 2012-09-03 07:39:53 +00:00
store Delete image from backend store on delete. 2012-09-03 12:58:36 -07:00
tests Fix cache not handling backend failures 2012-09-04 13:39:39 +01:00
__init__.py load gettext in __init__ to fix '_ is not defined' 2011-11-08 10:58:25 -08:00
client.py Mark bin/glance as deprecated 2012-08-14 14:14:41 -04:00
context.py Store context in local thread store for logging. 2012-08-01 12:05:49 -04:00
schema.py Filter out None values from v2 API image entity 2012-08-11 15:11:54 -07:00
version.py Move to tag-based versioning. 2012-08-12 16:10:03 +00:00