glance/glance/image_cache
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
..
drivers Catch pruner exception when no images are cached 2012-08-29 21:17:46 -07:00
__init__.py Fix cache not handling backend failures 2012-09-04 13:39:39 +01:00
base.py Don't use PasteDeploy for scrubber and cache daemons 2012-06-16 17:36:55 +01:00
cleaner.py Remove the conf passing PasteDeploy factories 2012-06-08 17:36:26 +01:00
prefetcher.py Provide stores access to the request context. 2012-07-20 09:50:59 -04:00
pruner.py Standardize logger instantiation 2012-06-25 08:27:08 -07:00