Bug 1538996

Summary: VM does not have deletion event on its own timeline on vsphere55
Product: Red Hat CloudForms Management Engine Reporter: thiebaut fischer <tfischer>
Component: ProvidersAssignee: Adam Grare <agrare>
Status: CLOSED CURRENTRELEASE QA Contact: Ievgen Zapolskyi <izapolsk>
Severity: medium Docs Contact:
Priority: high    
Version: 5.9.0CC: agrare, cpelland, gblomqui, hkataria, izapolsk, jfrey, jhardy, lavenel, mpovolny, obarenbo, simaishi
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.10.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1552677 (view as bug list) Environment:
Last Closed: 2019-02-11 14:09:35 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: 1552677    
Attachments:
Description Flags
missing event on the TL
none
event on provider without source_vm field none

Description thiebaut fischer 2018-01-26 10:51:55 UTC
Created attachment 1386512 [details]
missing event on the TL

Description of problem:
When going to the timeline of a deleted VM, it does not have any event in the category deletion. BUT the event appears on its host, provider, cluster. 
It works on all other vsphere version. 
ALSO there is no field source_vm, there is source_vm_location. The source_vm is present on other Vsphere versions as well. It usefull because used in our tests automations.

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

How reproducible:
Always

Steps to Reproduce:
1.create a vm on vsphere55
2. delete it
3.check its timeline

Actual results:
event in category deletion/removal 

Expected results:

no events

Additional info:
Events appears in the DB

Comment 2 thiebaut fischer 2018-01-26 10:52:31 UTC
Created attachment 1386513 [details]
event on provider without source_vm field

Comment 4 thiebaut fischer 2018-01-26 14:44:59 UTC
Adam, if you are asking me info in PM, im not able to see the PM's i have an issue with my account

Comment 5 Adam Grare 2018-01-27 23:53:41 UTC
What I think is happening here is if the VM is disconnected before the event is processed by the event handler.

We link events to VMs by ems_ref and ems_id here https://github.com/ManageIQ/manageiq/blob/master/app/models/ems_event.rb#L108-L109 but after the VM is archived we nullify the ems_id so that doesn't find the VM.

Comment 6 thiebaut fischer 2018-01-29 07:53:07 UTC
so will that be corrected?

Comment 8 Adam Grare 2018-01-29 19:34:59 UTC
> so will that be corrected?

working on it ;)

Comment 11 CFME Bot 2018-01-31 22:37:35 UTC
New commit detected on ManageIQ/vmware_web_service/master:
https://github.com/ManageIQ/vmware_web_service/commit/e4d3d56377317eefa7fae0de488d2be1ec6c2858

commit e4d3d56377317eefa7fae0de488d2be1ec6c2858
Author:     Adam Grare <agrare>
AuthorDate: Mon Jan 29 11:13:48 2018 -0500
Commit:     Adam Grare <agrare>
CommitDate: Mon Jan 29 14:32:10 2018 -0500

    Add VM UUID to event payload
    
    When a VM is disconnected the VM's UUID is the only property which can
    be used to link the VM to other entities e.g. events.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1538996

 lib/VMwareWebService/MiqVimEventMonitor.rb | 3 +++
 lib/VMwareWebService/VimPropMaps.rb        | 1 +
 2 files changed, 4 insertions(+)

Comment 12 CFME Bot 2018-02-07 21:39:27 UTC
New commit detected on ManageIQ/manageiq-providers-vmware/master:
https://github.com/ManageIQ/manageiq-providers-vmware/commit/9a9249d21749b73219fbdd1ee744f8670437bd5c

commit 9a9249d21749b73219fbdd1ee744f8670437bd5c
Author:     Adam Grare <agrare>
AuthorDate: Mon Jan 29 13:18:53 2018 -0500
Commit:     Adam Grare <agrare>
CommitDate: Wed Jan 31 18:48:45 2018 -0500

    Add VM uuid as the vm_uid_ems to the event payload
    
    Add the UUID for the VM to the event payload so that it can be used to
    find disconnected VMs when linking events.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1538996

 .../providers/vmware/infra_manager/event_parser.rb |   2 +
 manageiq-providers-vmware.gemspec                  |   2 +-
 .../infra_manager/event_data/task_event.yaml       | 148 +++++++++++++++++++++
 .../vmware/infra_manager/event_parser_spec.rb      |  10 ++
 4 files changed, 161 insertions(+), 1 deletion(-)
 create mode 100644 spec/models/manageiq/providers/vmware/infra_manager/event_data/task_event.yaml

Comment 13 CFME Bot 2018-02-07 21:56:55 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/5bea3d8e857f35529d118fd1219c5da27e20077e

commit 5bea3d8e857f35529d118fd1219c5da27e20077e
Author:     Adam Grare <agrare>
AuthorDate: Mon Jan 29 14:16:47 2018 -0500
Commit:     Adam Grare <agrare>
CommitDate: Mon Jan 29 15:56:38 2018 -0500

    Fix event linking to a disconnected VM
    
    When linking events to a VM we first try [ems_id, ems_ref] which fails
    to find a disconnected VM because the ems_id is nullified.  Next we try
    by uid_ems but no one was setting the field that we were using so this
    standardizes on an event key :vm_uid_ems (similar to :vm_location) which
    can be set by the EventParser to allow events to be connected to VMs
    after they are disconnected.
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1538996

 app/models/ems_event.rb       |  6 ++----
 spec/models/ems_event_spec.rb | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 4 deletions(-)

Comment 15 Adam Grare 2018-03-09 16:25:24 UTC
*** Bug 1534615 has been marked as a duplicate of this bug. ***

Comment 17 Ievgen Zapolskyi 2018-07-20 16:29:45 UTC
Verified in 5.10.0.4