Bug 1373492

Summary: Alert policy not working for OpenStack Provider
Product: Red Hat CloudForms Management Engine Reporter: Nikhil Gupta <ngupta>
Component: ProvidersAssignee: Tzu-Mainn Chen <tzumainn>
Status: CLOSED INSUFFICIENT_DATA QA Contact: Dmitry Misharov <dmisharo>
Severity: high Docs Contact:
Priority: high    
Version: 5.6.0CC: dmisharo, gblomqui, jfrey, jhardy, jocarter, lufu, mfeifer, ngupta, obarenbo, simaishi, tzumainn
Target Milestone: GA   
Target Release: cfme-future   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: control:openstack:alert
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-07-03 15:20:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: Bug
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: Openstack Target Upstream Version:

Description Nikhil Gupta 2016-09-06 12:11:07 UTC
Description of problem:
Alert policy not working for OpenStack Provider. I create a power state alert, but it never works as expected.

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

How reproducible:
Always

Steps to Reproduce:

1. Create a custom alert: 

    Go to Control -> Explorer -> Alerts

    Created Alert "Custom Alert - VM/Instance Power Off"

    Based On                 : VM and Instance
    What to Evaluate         : Expression(Custom)
    Driving Event            : VM Operation:VM Power Off
    Notification Frequency   : 1 Minute 

    Expression               : VM and Instance : Power State = "off"

    Set E-mail and Save.

2. I create a alert policy for it:

   - Create a blank policy named 'VM Power State Watchdog';
   - Attach a new condition to the policy we just created, and the expression of the condition should be 'VM and Instance : Power State = "off" ';
   - Assign an event named 'VM Power Off' to the policy;
   - Add a new action, whose action type is 'Evaluate Alerts', and set the evaluated alert to 'Custom Alert - VM/Instance Power Off';
   - Edit event 'VM Power Off' in the policy above, add the action we just created into 'Order of Actions if ALL Conditions are True', and apend 'generate log message' to both;
   - Create a new policy profile named 'VM Power State Watchdog Profile', and add the policy 'VM Power State Watchdog' into the profile.
   
3. Assign the policy to some VMware VMs and OpenStack instances. 


Actual results:
Alert is not sending mail when Openstack instance is powered off.

Expected results:
Alert is should send a mail when Openstack instance is powered off.

Additional info:
It does work if we change the Alerts Driving Event to 'VM Operation: VM Power off Request' and create a Alert Profile for the same as follows:

Go to Control -> Explorer -> Alert Profiles
    Created new "VM and Instance Alert Profiles" from Configuration.
    
    Added Description : VM off
    From "Alert Selection", moved "Custom Alert - VM/Instance Power Off" alert in to "Profile Alerts" section.
    Click 'Add' button.

    Then Select "VM off" alert profile
    Click 'Configuration' -> Select "Edit assignments for this Alert Profile"
    In Assign To : I have selected 'The Enterprise'. (In your case you have selected "Tagged VMs and Instances")

I have not created any separate alert policy in this approach.

However, Action type 'Evaluate Alerts' method should also work.

Comment 2 Greg McCullough 2016-09-08 19:40:44 UTC
Lucy - Can you work with Nikhil to identify the root cause of the issue.  If the logic works with the 'VM Operation: VM Power off Request' (which is an internally generated event) I am wondering if we are not getting an event from Openstack or getting a different event then expected.

Comment 3 Nikhil Gupta 2016-09-09 04:45:34 UTC
Hi Greg/Lucy,

Yes, it works with 'VM Operation: VM Power off Request' and it is working as expected when we create a Alert Profile but it is not working when we are creating a policy to evaluate alert.

We are not getting "Powered off" event for Openstack Provider that is why alert is not triggering when 'VM Operation: VM Power off' is set.

Lucy let me know if you require any help on this.

Regards,
Nikhil Gupta

Comment 4 Lucy Fu 2016-09-12 18:47:24 UTC
Hi Nikhil,

If your Openstack is configured correctly, you will see this message in the log:
  INFO -- : MIQ(EmsEventHelper#before_handle) Processing EMS event [compute.instance.power_off.end] chain_id [0] on EMS [9]...

If you don't see any Openstack events coming in, you may have not configured the Openstack server to send out the events.

If your Openstack is configured to sent out the events, then check if the ManageIQ::Providers::Openstack::CloudManager::EventCatcher is up and running by using rake evm:status.

It worked well with an Openstack instance in my testing. The alert was triggered when the instance was powered off.