Merge lp:~rconradharris/glance/lp817275 into lp:~hudson-openstack/glance/trunk

Proposed by Rick Harris
Status: Merged
Approved by: Josh Kearney
Approved revision: 165
Merged at revision: 166
Proposed branch: lp:~rconradharris/glance/lp817275
Merge into: lp:~hudson-openstack/glance/trunk
Diff against target: 44 lines (+14/-10)
1 file modified
glance/api/v1/images.py (+14/-10)
To merge this branch: bzr merge lp:~rconradharris/glance/lp817275
Reviewer Review Type Date Requested Status
Brian Lamar (community) Approve
Jay Pipes (community) Approve
Review via email: mp+69577@code.launchpad.net

Description of the change

Don't tee into the cache if that image is already being written.

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote :

lgtm.

review: Approve
Revision history for this message
Brian Lamar (blamar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'glance/api/v1/images.py'
2--- glance/api/v1/images.py 2011-07-25 20:38:57 +0000
3+++ glance/api/v1/images.py 2011-07-28 00:48:35 +0000
4@@ -214,26 +214,30 @@
5 if cache.enabled:
6 if cache.hit(id):
7 # hit
8- logger.debug("image cache HIT, retrieving image '%s'"
9- " from cache", id)
10+ logger.debug("image '%s' is a cache HIT", id)
11 image_iterator = get_from_cache(image, cache)
12 else:
13 # miss
14- logger.debug("image cache MISS, retrieving image '%s'"
15- " from store and tee'ing into cache", id)
16+ logger.debug("image '%s' is a cache MISS", id)
17
18- # We only want to tee-into the cache if we're not currently
19- # prefetching an image
20- image_id = image['id']
21- if cache.is_image_currently_prefetching(image_id):
22+ # Make sure we're not already prefetching or caching the image
23+ # that just generated the miss
24+ if cache.is_image_currently_prefetching(id):
25+ logger.debug("image '%s' is already being prefetched,"
26+ " not tee'ing into the cache", id)
27+ image_iterator = get_from_store(image)
28+ elif cache.is_image_currently_being_written(id):
29+ logger.debug("image '%s' is already being cached,"
30+ " not tee'ing into the cache", id)
31 image_iterator = get_from_store(image)
32 else:
33 # NOTE(sirp): If we're about to download and cache an
34 # image which is currently in the prefetch queue, just
35 # delete the queue items since we're caching it anyway
36- if cache.is_image_queued_for_prefetch(image_id):
37- cache.delete_queued_prefetch_image(image_id)
38+ if cache.is_image_queued_for_prefetch(id):
39+ cache.delete_queued_prefetch_image(id)
40
41+ logger.debug("tee'ing image '%s' into cache", id)
42 image_iterator = get_from_store_tee_into_cache(
43 image, cache)
44 else:

Subscribers

People subscribed via source and target branches