Bug 1381233

Summary: Can not delete glance image that has current cinder volume created using that same image
Product: Red Hat OpenStack Reporter: Jeremy <jmelvin>
Component: openstack-glanceAssignee: Cyril Roelandt <cyril>
Status: CLOSED NOTABUG QA Contact: Mike Abrams <mabrams>
Severity: high Docs Contact:
Priority: high    
Version: 8.0 (Liberty)CC: cyril, eglynn, eharney, ekuvaja, fpercoco, pgrist, srevivo, tshefi
Target Milestone: ---Keywords: Triaged, Unconfirmed, ZStream
Target Release: 8.0 (Liberty)Flags: tshefi: automate_bug-
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-01-15 15:50: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:

Description Jeremy 2016-10-03 13:27:29 UTC
Description of problem: Attempting to delete a glance image that has been used to create a bootable volume fails. The customer wants to free up space in glance is the reason for deleting the image. Glance seems to be backed by ceph, which is why we see rbd errors in the traceback. The error seen when trying to delete is: 
[root@xlabostkdir1 scripts(LIBERTY_keystone_admin)]# openstack image delete 5efda7da-4725-4eaa-aeeb-f4d0a56c2fb5
409 Conflict: Image 5efda7da-4725-4eaa-aeeb-f4d0a56c2fb5 could not be deleted because it is in use: The image cannot be deleted because it is in use through the backend store outside of Glance. (HTTP 409)


Version-Release number of selected component (if applicable):
openstack-glance-11.0.1-4.el7ost.noarch
ceph-0.94.5-9.el7cp.x86_64 

How reproducible:
100%

Steps to Reproduce:
1. create volume using glance image
2. delete image and notice it fails
3.

Actual results:
fails to delete image

Expected results:
should be able to delete image to fee up space in glance

Additional info:
Seems similar to : BZ https://bugzilla.redhat.com/show_bug.cgi?id=1323714 , however the traceback is different and RHOSP version is different so I am opening a new BZ for tracking. 

image is : 
openstack image show bootimage.rhel-testinit2

+------------------+-------------------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                                       |
+------------------+-------------------------------------------------------------------------------------------------------------+
| checksum         | e25e86ff706b848811cfdad278f67fbf                                                                            |
| container_format | bare                                                                                                        |
| created_at       | 2016-09-08T15:32:38Z                                                                                        |
| disk_format      | raw                                                                                                         |
| file             | /v2/images/5efda7da-4725-4eaa-aeeb-f4d0a56c2fb5/file                                                        |
| id               | 5efda7da-4725-4eaa-aeeb-f4d0a56c2fb5                                                                        |
| min_disk         | 0                                                                                                           |
| min_ram          | 0                                                                                                           |
| name             | bootimage.rhel-testinit2                                                                                    |
| owner            | 5868c9b7a0f34e659675d6a842dec66d                                                                            |
| properties       | direct_url='rbd://17ae2be4-b8f5-4728-b839-c08a26d91662/images-01/5efda7da-4725-4eaa-aeeb-f4d0a56c2fb5/snap' |
| protected        | False                                                                                                       |
| schema           | /v2/schemas/image                                                                                           |
| size             | 42949672960                                                                                                 |
| status           | active                                                                                                      |
| updated_at       | 2016-09-08T15:39:52Z                                                                                        |
| virtual_size     | None                                                                                                        |
| visibility       | private                                                                                                     |
+------------------+-----------------


Volume created by image is :  bd3f78d3-7362-4916-9614-c374d46bc714


ERRORS seen in /glance/api.log

2016-09-30 09:19:07.817 10670 DEBUG glance_store._drivers.rbd [req-0a4d4e60-5040-4ca9-b124-ba15a89d9dee 134f7b56c2e24e49a6e9cca3275991c2 5868c9b7a0f34e659675d6a842dec66d - - -] _cleanup_image() failed delete /usr/lib/python2.7/site-packages/glance_store/_drivers/rbd.py:485
2016-09-30 09:19:07.817 10670 ERROR glance_store._drivers.rbd Traceback (most recent call last):
2016-09-30 09:19:07.817 10670 ERROR glance_store._drivers.rbd   File "/usr/lib/python2.7/site-packages/glance_store/_drivers/rbd.py", line 483, in delete
2016-09-30 09:19:07.817 10670 ERROR glance_store._drivers.rbd     self._cleanup_image(target_pool, loc.image, loc.snapshot)
2016-09-30 09:19:07.817 10670 ERROR glance_store._drivers.rbd   File "/usr/lib/python2.7/site-packages/glance_store/_drivers/rbd.py", line 353, in _cleanup_image
2016-09-30 09:19:07.817 10670 ERROR glance_store._drivers.rbd     raise exceptions.InUseByStore()
2016-09-30 09:19:07.817 10670 ERROR glance_store._drivers.rbd InUseByStore: The image cannot be deleted because it is in use through the backend store outside of Glance.
2016-09-30 09:19:07.817 10670 ERROR glance_store._drivers.rbd
2016-09-30 09:19:07.826 10670 WARNING glance.api.v2.images [req-0a4d4e60-5040-4ca9-b124-ba15a89d9dee 134f7b56c2e24e49a6e9cca3275991c2 5868c9b7a0f34e659675d6a842dec66d - - -] Image 5efda7da-4725-4eaa-aeeb-f4d0a56c2fb5 could not be deleted because it is in use: The image cannot be deleted because it is in use through the backend store outside of Glance.
2016-09-30 09:19:07.828 10670 INFO eventlet.wsgi.server [req-0a4d4e60-5040-4ca9-b124-ba15a89d9dee 134f7b56c2e24e49a6e9cca3275991c2 5868c9b7a0f34e659675d6a842dec66d - - -] 192.168.101.12 - - [30/Sep/2016 09:19:07] "DELETE /v2/images/5efda7da-4725-4eaa-aeeb-f4d0a56c2fb5 HTTP/1.1" 409 512 0.208476
?InUseBy

Comment 2 Cyril Roelandt 2018-01-15 15:50:16 UTC
This is an old bug, and honestly, it seems like the expected behaviour. Closing it for now, feel free to re-open if this is still an issue.