Bug 2031740

Summary: Attempting to delete an image from Glance that is in use breaks subsequent usage of that image
Product: Red Hat OpenStack Reporter: Giulio Fidente <gfidente>
Component: python-glance-storeAssignee: Rajat Dhasmana <rdhasman>
Status: CLOSED ERRATA QA Contact: Tzach Shefi <tshefi>
Severity: high Docs Contact:
Priority: high    
Version: 16.2 (Train)CC: akekane, apevec, athomas, cyril, eglynn, eharney, gcharot, lhh, ltoscano, senrique, tshefi, udesale
Target Milestone: z2Keywords: Triaged
Target Release: 16.2 (Train on RHEL 8.4)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-glance-store-1.0.2-2.20220111043147.79e043a Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-03-23 22:12:27 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:    
Bug Blocks: 2032458, 2044245    

Description Giulio Fidente 2021-12-13 11:20:17 UTC
Implement support for Ceph clone v2 in the RBD driver

This will permit deletion of images which still have COW clones created either by Cinder or Nova in different pools, deferring to Ceph management of the "trash" [1]. It is complementary to the corresponding Cinder feature [2]

1. https://github.com/ceph/ceph/pull/27521
2. https://bugzilla.redhat.com/show_bug.cgi?id=1997715

Comment 7 Tzach Shefi 2022-02-24 21:04:59 UTC
Verified on:
python3-glance-store-1.0.2-2.20220111043148.el8ost.noarch


On a ceph backed deployment,
First I had to bump up the min client version

ceph osd set-require-min-compat-client mimic

To confirm it works 
[root@controller-2 /]# ceph osd dump | grep client
require_min_compat_client mimic

FYI you must set this before you upload the image, 
at first I had set it after the image was uploaded and verification failed. 


I used a script to upload a cirros image to Glance
and create a volume from said image:


(overcloud) [stack@undercloud-0 ~]$ cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| ID                                   | Status    | Name         | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| fe409ae3-d227-4aab-b874-bb1b5c39aad3 | available | Pansible_vol | 1    | tripleo     | true     |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

(overcloud) [stack@undercloud-0 ~]$ glance image-list
+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
| 33d0d4a6-36d9-45a1-9e3b-ff5bcd7e5b15 | cirros |
+--------------------------------------+--------+

Now lets try to delete the image, it should fail:

(overcloud) [stack@undercloud-0 ~]$ glance image-delete 33d0d4a6-36d9-45a1-9e3b-ff5bcd7e5b15
Unable to delete image '33d0d4a6-36d9-45a1-9e3b-ff5bcd7e5b15' because it is in use.

Great we expected this error, plus we see the image is still available.

(overcloud) [stack@undercloud-0 ~]$ glance image-list
+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
| 33d0d4a6-36d9-45a1-9e3b-ff5bcd7e5b15 | cirros |
+--------------------------------------+--------+


Lastly we try to consume this image again, before this fix this would fail

(overcloud) [stack@undercloud-0 ~]$ cinder create 1 --image 33d0d4a6-36d9-45a1-9e3b-ff5bcd7e5b15 --name volBFromImageAfterDelete
+--------------------------------+--------------------------------------+
| Property                       | Value                                |
+--------------------------------+--------------------------------------+
| attachments                    | []                                   |
| availability_zone              | nova                                 |
| bootable                       | false                                |
| consistencygroup_id            | None                                 |
| created_at                     | 2022-02-24T20:51:40.000000           |
| description                    | None                                 |
| encrypted                      | False                                |
| id                             | 790d43e1-378e-478e-b10a-b1a9cd05f620 |
| metadata                       | {}                                   |
| migration_status               | None                                 |
| multiattach                    | False                                |
| name                           | volBFromImageAfterDelete             |
| os-vol-host-attr:host          | None                                 |
| os-vol-mig-status-attr:migstat | None                                 |
| os-vol-mig-status-attr:name_id | None                                 |
| os-vol-tenant-attr:tenant_id   | 4e0fc4a8b79d4dfba3ee51ae20d0a4df     |
| replication_status             | None                                 |
| size                           | 1                                    |
| snapshot_id                    | None                                 |
| source_volid                   | None                                 |
| status                         | creating                             |
| updated_at                     | None                                 |
| user_id                        | 7165e9408a0a447681534d9c5f8e6b5a     |
| volume_type                    | tripleo                              |
+--------------------------------+--------------------------------------+

Now however the image isn't broken after the failed deletion attempt. 

(overcloud) [stack@undercloud-0 ~]$ cinder list
+--------------------------------------+-----------+--------------------------+------+-------------+----------+-------------+
| ID                                   | Status    | Name                     | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------------------+------+-------------+----------+-------------+
| 790d43e1-378e-478e-b10a-b1a9cd05f620 | available | volBFromImageAfterDelete | 1    | tripleo     | true     |             |
| fe409ae3-d227-4aab-b874-bb1b5c39aad3 | available | Pansible_vol             | 1    | tripleo     | true     |             |
+--------------------------------------+-----------+--------------------------+------+-------------+----------+-------------+

As can be seen above both volumes are available,
image wasn't delete and is still usable, I call this verified.

Comment 12 errata-xmlrpc 2022-03-23 22:12:27 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 (Release of components for Red Hat OpenStack Platform 16.2.2), 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-2022:1001