Openstack errors

Fleio uses django signals to notify about OpenStack error events and send details about them.

Configuring fleio to send emails on openstack error events

Using a simple setting that you can set in the django settings file, you can specify the openstack error events you wish to send emails for and to whom. The setting may look like this:

SEND_OPENSTACK_ERRORS_ON_EVENTS = {
    'resize_instance': {
        'error_receivers': {
            'staff_users': False,
            'custom_emails': ['youremail@youremailprovider.com', ],
        }
    },
    'another_event': {
        'error_receivers': {
                'staff_users': True,
                'custom_emails': [],
        }
    }
}

As you can see, for each event you want to send emails define a key in the SEND_OPENSTACK_ERRORS_ON_EVENTS dictionary. Events are notifications sent by nova. Examples: “resize_instance”, “compute_task.build_instances”, etc.

Fleio uses other custom event names to ensure we catch every situation:

  • fleio_instance_create

Emails are sent just for those events set in the SEND_OPENSTACK_ERRORS_ON_EVENTS dictionary. Also, emails are sent differently for every notification, based on their related error_receivers attribute that you can define like in the above example.

Note that you can catch all notification events and send emails for them using the asterisk (“*”) as an attribute in the dictionary instead of using an event name. If you add both asterisk attribute and some notification names, the error receivers defined for the custom notifications names will precede those set using the asterisk attribute.

Using the signal to manipulate openstack error events

You can catch the signal and write your own python code and manipulate those errors in any way you want.

The signal is located in fleio/openstack/signals/signals.py file

So, after creating your python file you can import it like this:

from fleio.openstack.signals.signals import openstack_error

Then you’ll need to create a receiver function which receives the signal along with the details. Read more about it in the Django documentation. You can find some inspiration from the function that sends emails on these events located in fleio/openstack/signals/handlers.py file, the function being called “notify_on_openstack_error”. You can see that in this method we used a class called NotificationErrorParser which should help you get the error message and arguments from the openstack request exception if you want to use it. Otherwise, manipulate the arguments in the way you want.

Parameters sent for this function are:

  • event_type: the name of the event
  • payload: openstack exception payload
  • region: the exception related region