Can not create alarm successfully according to examples in community

Bug #1245362 reported by Zhang Yun
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
High
Ildiko Vancsa
Havana
Fix Released
High
Ildiko Vancsa

Bug Description

Steps:
1. Install ceilometer by install scripts successfully.
2. Create an alarm according to examples in community - http://docs.openstack.org/developer/ceilometer/webapi/v2.html

POST http://10.1.0.182:8777/v2/alarms
body:
{
    "alarm_actions": [
        "http://site:8000/alarm"
    ],
    "alarm_id": null,
    "combination_rule": null,
    "description": "An alarm",
    "enabled": true,
    "insufficient_data_actions": [
        "http://site:8000/nodata"
    ],
    "name": "SwiftObjectAlarm11",
    "ok_actions": [
        "http://site:8000/ok"
    ],
    "project_id": "c96c887c216949acbdfbd8b494863567",
    "repeat_actions": false,
    "state": "ok",
    "state_timestamp": "2013-10-08T12:32:07.253899",
    "threshold_rule": null,
    "timestamp": "2013-10-08T12:32:07.253890",
    "type": "threshold",
    "user_id": "c96c887c216949acbdfbd8b494863567"
}

The return result is 500 Internal Server Error:
{
    "error_message": {
        "debuginfo": null,
        "faultcode": "Server",
        "faultstring": "CL-EFFDED5 Alarm with that name exists"
    }
}

But when running "ceilometer alarm-list", there is no same alarm name exists.

[root@osee15-control01 ˜]# ceilometer alarm-list
+---------------------+-----------------------------------------------------------------+-------------------+---------+------------+--------------------------------------+----------------------------------+----------------------------------+
| Name | Description | State | Enabled | Continuous | Alarm ID | User ID | Project ID |
+---------------------+-----------------------------------------------------------------+-------------------+---------+------------+--------------------------------------+----------------------------------+----------------------------------+
| zyalarm-imagesize | Alarm when image.size is eq a avg of 1.0 over 60 seconds | insufficient data | True | False | ec5dcce2-5278-4180-8918-fd2718268023 | aa5b233474d14b6fb93e99161a637599 | f5f2932bab5d4930998e7f80e8470d8f |
| zyalarm-imagesize1 | Alarm when image.size is eq a avg of 9761280.0 over 600 seconds | insufficient data | True | False | ee588dc3-5b3d-4327-8c0f-04b096e709eb | aa5b233474d14b6fb93e99161a637599 | f5f2932bab5d4930998e7f80e8470d8f |
| zyalarm-imagesize2 | Alarm when image.size is eq a avg of 9761280.0 over 1 seconds | insufficient data | True | False | aef96037-1474-4010-b9ee-74c298c88e72 | aa5b233474d14b6fb93e99161a637599 | f5f2932bab5d4930998e7f80e8470d8f |
| zyalarm-imagesize22 | Alarm when image.size is eq a avg of 9761280.0 over 3 seconds | insufficient data | True | False | 83fb9b4b-0e1c-40ee-bf21-d2164d864cab | aa5b233474d14b6fb93e99161a637599 | f5f2932bab5d4930998e7f80e8470d8f |
+---------------------+-----------------------------------------------------------------+-------------------+---------+------------+--------------------------------------+----------------------------------+----------------------------------+
[root@osee15-control01 ˜]#

And from the /var/log/ceilometer/api.log, it prompts below error:

2013-10-10 08:09:35.612 23872 ERROR wsme.api [-] Server-side error: "'NoneType' object has no attribute 'as_dict'". Detail:
Traceback (most recent call last):

  File "/usr/lib/python2.6/site-packages/wsmeext/pecan.py", line 72, in callfunction
    result = f(self, *args, **kwargs)

  File "/usr/lib/python2.6/site-packages/ceilometer/api/controllers/v2.py", line 1393, in post
    change = data.as_dict(storage.models.Alarm)

  File "/usr/lib/python2.6/site-packages/ceilometer/api/controllers/v2.py", line 1156, in as_dict
    d['rule'] = getattr(self, "%s_rule" % self.type).as_dict()

AttributeError: 'NoneType' object has no attribute 'as_dict'

Expected results: Alarm should create successfully following example in community.

Julien Danjou (jdanjou)
Changed in ceilometer:
status: New → Triaged
importance: Undecided → High
tags: added: havana-backport-potential
Changed in ceilometer:
assignee: nobody → Vladimir Vechkanov (vvechkanov)
Revision history for this message
Vladimir Vechkanov (vvechkanov) wrote :

I check alarm creating by your (and exmple) command and get return error message:
{
    "error_message": {
     "debuginfo": null,
     "faultcode": "Server",
      "faultstring": "'NoneType' object has no attribute 'as_dict'"
    }
}

To fix this error you should change body of your request.
Instead line:
   threshold_rule": null,
You should use lines, for example:
    "threshold_rule": {
        "threshold": "50",
        "meter_name": "image.update",
    },
So your new body should be like this:
{
    "alarm_actions": [
        "http://site:8000/alarm"
    ],
    "alarm_id": null,
    "combination_rule": null,
    "description": "An alarm",
    "enabled": true,
    "insufficient_data_actions": [
        "http://site:8000/nodata"
    ],
    "name": "SwiftObjectAlarm",
    "ok_actions": [
        "http://site:8000/ok"
    ],
    "project_id": "c96c887c216949acbdfbd8b494863567",
    "repeat_actions": false,
    "state": "ok",
    "state_timestamp": "2013-10-08T12:32:07.253899",
    "threshold_rule": {
        "threshold": "50",
        "meter_name": "image.update"
    },
    "timestamp": "2013-10-30T11:03:53.483447",
    "type": "threshold",
    "user_id": "c96c887c216949acbdfbd8b494863567"
}

An appropriate changes to the examples will be added.

I think that this changes will also fix error "CL-EFFDED5 Alarm with that name exists". But if it will show again, please comment here or let us know in any other way.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (master)

Fix proposed to branch: master
Review: https://review.openstack.org/68071

Changed in ceilometer:
assignee: Vladimir Vechkanov (vvechkanov) → Ildiko Vancsa (ildiko-vancsa)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (stable/havana)

Fix proposed to branch: stable/havana
Review: https://review.openstack.org/68120

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ceilometer (master)

Reviewed: https://review.openstack.org/68071
Committed: https://git.openstack.org/cgit/openstack/ceilometer/commit/?id=7b0f1c87795fecedce7e1d4d701fafcd6ba90581
Submitter: Jenkins
Branch: master

commit 7b0f1c87795fecedce7e1d4d701fafcd6ba90581
Author: Ildiko Vancsa <email address hidden>
Date: Tue Jan 21 11:21:06 2014 +0100

    Fix the Alarm documentation of Web API V2

    Correct the Alarm example on the API documentation to contain a
    valid Alarm sample and complete the Note section with information
    about the connection between the type and rules fields of the
    Alarm.

    Fixes bug #1245362

    Change-Id: Id7209d3f7a7ab29a50bdb1dfbe90937b1c7c6c8d

Changed in ceilometer:
status: In Progress → Fix Committed
Alan Pevec (apevec)
tags: removed: havana-backport-potential
Revision history for this message
Zhang Yun (zhangyun) wrote : Yun N Zhang is out of the office.

I will be out of the office starting 01/28/2014 and will not return until
02/10/2014.

I will have limited internet access during 1/28 to 2/2, any urgent thing,
please call me 13811788324.

gordon chung (chungg)
Changed in ceilometer:
milestone: none → icehouse-3
Revision history for this message
Eoghan Glynn (eglynn) wrote :
Thierry Carrez (ttx)
Changed in ceilometer:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: icehouse-3 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.