Bug 1641011 - Snapshot is not getting deleted after smartstate analysis is done for instance booted from a Cinder volume
Summary: Snapshot is not getting deleted after smartstate analysis is done for instanc...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Providers
Version: 5.9.4
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: GA
: 5.10.0
Assignee: Scott Seago
QA Contact: Dave Johnson
URL:
Whiteboard:
Depends On:
Blocks: 1660582
TreeView+ depends on / blocked
 
Reported: 2018-10-19 12:41 UTC by Nikhil Gupta
Modified: 2022-03-13 15:49 UTC (History)
17 users (show)

Fixed In Version: 5.10.0.30
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1660582 (view as bug list)
Environment:
Last Closed: 2019-02-12 16:52:46 UTC
Category: Bug
Cloudforms Team: Openstack
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Nikhil Gupta 2018-10-19 12:41:57 UTC
Description of problem:
Snapshot is not getting deleted after smartstate analysis is done for instance booted from a Cinder volume.
The image and volume are getting deleted but snapshot remains as it is.


Version-Release number of selected component (if applicable):
cfme 5.9.4.7.20180829201904_ced41ae
Red Hat OpenStack 10

How reproducible:
Always

Steps to Reproduce:
1. Create an OpenStack instance booted from a Cinder volume
 a. Log-in to Horizon
 b. Select an appropriate project
 c. Select "Volumes"
 d. Select "Create a Volume"
 e. Under "Volume Source"
 f. Under "Use image as a source" select an appropriate image
 g. Select "Instances"
 h. Select "Launch Instance"
 i. Under "Instance boot source" select "Boot from volume"
 j. Under "Volume" select the volume created in (c)-(f) 
2. Log-in to the Cloudforms appliance, and select the instance created in (1) (perform a "Refresh Relationships and Power States" for the provider if required to discover the instance)
3. Select "Configuration" -> "Perform SmartState Analysis" for the instance


Actual results:
Snapshot is not deleted from OpenStack provider

Expected results:
Snapshot should be deleted after smartstate analysis is completed successfully.

Comment 11 Scott Seago 2018-11-16 22:03:32 UTC
I'll be away next week, so here's an update as to where I am with this:

Basically what's going on is that the snapshot that the smartstate analysis takes of the instance uses the nova image create api call which creates an image from the instance. However, in the specific case of an instance booted from a volume (rather than from an image), in addition to creating the image object (which in the boot-from-volume case seems to have a size of zero), there's also a volume snapshot created, since the instance's disk data is in that volume rather than in an image. The same thing happens if I create the image via the OpenStack CLI. an image-booted instance just gets the snapshot image, but a volume-booted instance gets the snapshot image *and* a volume snapshot. The volume snapshot's snapshot_id is contained in the properties metadata of the image object, though, so the solution here should be to check for snapshot_id in the image metadata before deleting it (in delete_evm_snapshot in MiqOpenStackInstance.rb) and if it's there, then delete the volume snapshot *and* the image.

My first attempt to do this today failed, though, since for some reason the properties aren't showing up via fog-openstack. I'll need to debug that when I return, since I need access to the snapshot_id in order to make sure the volume snapshot is also deleted along with the image.

Comment 12 Alexander Demicev 2018-11-20 13:51:50 UTC
Hi, 
I will work on this BZ while Scott is on PTO.

Comment 14 Scott Seago 2018-11-27 21:13:32 UTC
It looks like that fog-openstack PR won't be needed after all. The only necessary changes are in the manageiq-smartstate PR here: https://github.com/ManageIQ/manageiq-smartstate/pull/83

Comment 16 CFME Bot 2018-11-29 16:27:44 UTC
New commit detected on ManageIQ/manageiq-smartstate/master:

https://github.com/ManageIQ/manageiq-smartstate/commit/c99b01378d78b6606de35c93578f5d811bd313b3
commit c99b01378d78b6606de35c93578f5d811bd313b3
Author:     Scott Seago <sseago>
AuthorDate: Tue Nov 27 16:08:54 2018 -0500
Commit:     Scott Seago <sseago>
CommitDate: Tue Nov 27 16:08:54 2018 -0500

    bug 1641011: delete snapshot after smartstate analysis

    fixes https://bugzilla.redhat.com/show_bug.cgi?id=1641011

    For instances launched from volumes, the volume snapshot was
    not being deleted after smartstate analysis.

    With this PR, it gets deleted if present.

 lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackInstance.rb | 23 +
 1 file changed, 23 insertions(+)

Comment 17 Nikhil Gupta 2018-11-30 01:02:00 UTC
Hi Scott and Alexander,

I tested this PR and it is working like a charm.
Now, if an instance is launched using volumes, the snapshot is getting deleted after smartstate is finished successfully.

Thank you,
Niks

Comment 21 Jad Haj Yahya 2018-12-20 15:58:23 UTC
Looks like smart analysis is not working well after following scenario above

tested on 5.10.0.30

Comment 23 Scott Seago 2019-01-02 15:35:42 UTC
Marek -- I suspect this failed for Jadh because he's not running with the updated manageiq-smartstate gem, since we lock that version in Gemfile. I'll create a PR to update the Gemfile to use 0.2.18

Comment 24 Scott Seago 2019-01-02 17:53:07 UTC
Gemfile PR posted: https://github.com/ManageIQ/manageiq/pull/18319

Comment 25 Marek Aufart 2019-01-03 08:35:25 UTC
PR was merged to master.

Comment 27 Scott Seago 2019-01-07 18:06:07 UTC
I just confirmed that, at least in git, v0.2.18 includes the fix. Jadh -- what version of manageiq-smartstate was installed when this failed for you? If it's 0.2.18, can you give us some more details (and logs, etc.) on what happened, since the fix was previously working for both myself and Nikhil

Comment 29 Jad Haj Yahya 2019-01-08 07:32:43 UTC
env: https://10.9.76.165/

5.10.0.30.20181218191323_900a416

How can i tell what is manageiq-smartstate version ?

Comment 30 Jad Haj Yahya 2019-01-08 08:53:34 UTC
There was misunderstanding on reproducing the bug 
Re-Verified on 5.10.0.30


Note You need to log in before you can comment on or make changes to this bug.