update alarm time constraints fail but without helpful error message

Bug #1439207 reported by ZhiQiang Fan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-ceilometerclient
Fix Released
Low
ZhiQiang Fan

Bug Description

# ceilometer alarm-threshold-update 40fc94d3-a7a1-4e15-b9b7-1ebcbd80058c --time-constraint 'start=30 17 31 3 *;duration=3600'
'name'

# ceilometer -d alarm-threshold-update 40fc94d3-a7a1-4e15-b9b7-1ebcbd80058c --time-constraint 'start=30 17 31 3 *;duration=3600'
Traceback (most recent call last):
  File "/usr/local/bin/ceilometer", line 10, in <module>
    sys.exit(main())
  File "/opt/stack/python-ceilometerclient/ceilometerclient/shell.py", line 299, in main
    CeilometerShell().main(args)
  File "/opt/stack/python-ceilometerclient/ceilometerclient/shell.py", line 248, in main
    args.func(client, args)
  File "/opt/stack/python-ceilometerclient/ceilometerclient/v2/shell.py", line 462, in _wrapped
    return func(*args, **kwargs)
  File "/opt/stack/python-ceilometerclient/ceilometerclient/v2/shell.py", line 190, in wrapped
    return func(cc, args)
  File "/opt/stack/python-ceilometerclient/ceilometerclient/v2/shell.py", line 190, in wrapped
    return func(cc, args)
  File "/opt/stack/python-ceilometerclient/ceilometerclient/v2/shell.py", line 800, in do_alarm_threshold_update
    alarm = cc.alarms.update(args.alarm_id, **fields)
  File "/opt/stack/python-ceilometerclient/ceilometerclient/v2/alarms.py", line 163, in update
    updated.get('time_constraints', []), kwargs)
  File "/opt/stack/python-ceilometerclient/ceilometerclient/v2/alarms.py", line 138, in _merge_time_constraints
    if old_tc['name'] == tc['name']:#tc.get('name'): # if names match, merge
KeyError: 'name'

after fix:
# ceilometer alarm-threshold-update 40fc94d3-a7a1-4e15-b9b7-1ebcbd80058c --time-constraint 'start=30 17 31 3 *;duration=3600'
Invalid input for field/attribute name. Value: 'None'. Mandatory field missing. (HTTP 400) (Request-ID: req-85662cc1-e465-42b4-8d38-690f7ae30a02)

ZhiQiang Fan (aji-zqfan)
Changed in python-ceilometerclient:
assignee: nobody → ZhiQiang Fan (aji-zqfan)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-ceilometerclient (master)

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

Changed in python-ceilometerclient:
status: New → In Progress
Lianhao Lu (lianhao-lu)
Changed in python-ceilometerclient:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-ceilometerclient (master)

Reviewed: https://review.openstack.org/169774
Committed: https://git.openstack.org/cgit/openstack/python-ceilometerclient/commit/?id=16880fcaebb9a950c7ad7ca17ff87b000645f2ac
Submitter: Jenkins
Branch: master

commit 16880fcaebb9a950c7ad7ca17ff87b000645f2ac
Author: ZhiQiang Fan <email address hidden>
Date: Wed Apr 1 22:22:07 2015 +0800

    print user friendly error message for alarm update time constraints

    Currently, if we update an alarm with wrong time constraint which
    doesn't get name defined, then the shell only prints a very simple
    string 'name'.

    This is because our code assume name field has always been specified,
    however it is not true, then KeyError exception will be raised but not
    handled well, finally user only gets an implicit message.

    This patch uses dict.get() for name field, and sends request (may be broken)
    to ceilometer api, then extracts error message from response.

    Change-Id: I086c4ec790acc22767ba7f5e43dbcf73f3af5dff
    Closes-Bug: #1439207

Changed in python-ceilometerclient:
status: In Progress → Fix Committed
Changed in python-ceilometerclient:
milestone: none → 1.3.0
status: Fix Committed → Fix Released
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.