Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1434499

Summary: Image-Volume Cache Caches Multiple Copies of Same Image on First Launch
Product: Red Hat OpenStack Reporter: Alan Bishop <abishop>
Component: openstack-cinderAssignee: Alan Bishop <abishop>
Status: CLOSED ERRATA QA Contact: Tzach Shefi <tshefi>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 8.0 (Liberty)CC: abishop, bschmaus, eharney, lruzicka, mzheng, nlevinki, srevivo, tshefi
Target Milestone: z3Keywords: Triaged, ZStream
Target Release: 10.0 (Newton)   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: openstack-cinder-9.1.2-3.el7ost Doc Type: Bug Fix
Doc Text:
Concurrent requests to create a cinder volume from the same glance image could result in multiple entries in cinder image cache. Consequently, more disk space was used than necessary. A synchronization lock has been added that prevents multiple entries in the image cache. As a result no more than one entry in the cinder image cache will be generated.
Story Points: ---
Clone Of: 1434494
: 1434500 (view as bug list) Environment:
Last Closed: 2017-06-28 15:38:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1434494    
Bug Blocks: 1377891, 1434500    

Description Alan Bishop 2017-03-21 15:48:25 UTC
+++ This bug was initially created as a clone of Bug #1434494 +++

+++ This bug was initially created as a clone of Bug #1377891 +++

Description of problem:

If a customer enables Image-Volume Cache in Cinder, it works correctly if you launch a single instance using an image that has never been cached before.  The image will get cached and subsequent launches of instances will rely on that cached imaged.

However if you launch 2+ instances simultaneously, the volume cache will store a image cache copy for each instance, instead of one.

I suspect the cause is that when you launch 2 or more instances in Nova, they all check for a cached image that is not there and hence causes each nova instance to cache its own image.  When launching a group of instances, we need the check to happen once and ensure all threads for each instance are aware and only cache the image once. 

Version-Release number of selected component (if applicable):
8.0

How reproducible:
100%

Steps to Reproduce:
1.Enable Image-Volume Cache in Cinder
2.Launch 2+ instances simultaneously using an image that has never been cached
3.Each instance will end up caching the image in the Volume-Cache

Actual results:


Expected results:
One image should be cached per glance image

Additional info:

Comment 2 Tzach Shefi 2017-04-05 18:48:22 UTC
Verified, only one image cache shows up on cinder list. 

# rpm -qa openstack-cinder
openstack-cinder-9.1.3-1.el7ost.noarch

On Cinder.conf 
enable and set these two
cinder_internal_tenant_project_id = 5907b3d67.....
cinder_internal_tenant_user_id = .......
*In my case used admin project and admin user ID's

under backend section 
image_volume_cache_enabled=True

Restart cinder volume service. 

Uploaded an image
#watched -n 5 -d cinder list --all-tenants

To create a few volumes at once:
$ for i in 1 2 3; do cinder create 1 --image cirros  ; done

For the ^ input three volumes will be create, as seen below we have 4 lines. 
The forth line is image-cache and as expected we only get one such line despite us booting 3 volumes from same image, 

#cinder list --all-tenants                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

+--------------------------------------+----------------------------------+-----------+--------------------------------------------+------+-------------+----------+-------------+
| ID                                   | Tenant ID                        | Status    | Name                                       | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+----------------------------------+-----------+--------------------------------------------+------+-------------+----------+-------------+
| 2c133ff1-ae57-4e63-96e2-2f48c8c145e9 | 5907b3d677114debba23c4e417612ee8 | available | -                                          | 1    | -           | true     |             |
| 4fffed5e-a2cb-4979-99db-6dbdc8c1073b | 5907b3d677114debba23c4e417612ee8 | available | -                                          | 1    | -           | true     |             |
| 86e692e5-c219-47f5-a5a9-c238d0775f4e | 5907b3d677114debba23c4e417612ee8 | available | -                                          | 1    | -           | true     |             |
| e167ab9a-fdc7-4439-bea4-630c6db44e92 | 5907b3d677114debba23c4e417612ee8 | available | image-382058da-44db-4e5d-a2ad-c8b92090dac4 | 1    | -           | false    |             |
+--------------------------------------+----------------------------------+-----------+--------------------------------------------+------+-------------+----------+-----------

Comment 8 errata-xmlrpc 2017-06-28 15:38:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:1591