fail parameter validation in pecan shouldn't raise HTTPInternalServerError

Bug #1320430 reported by Liusheng
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
Medium
Unassigned
Juno
Fix Released
Medium
Eoghan Glynn
python-ceilometerclient
In Progress
Undecided
Unassigned

Bug Description

Currently , ceilometer use wsmeext.pecan to validate some parameters of a model (such as Alarm), but if parameter validation fails, ceilometer will raise HTTPInternalServerError.

Mostly it should raise BadRequest error. e.g.

ceilometer --debug alarm-threshold-create -m instance --threshold 20 --state abc --name test_alarm

it returns:
ceilometerclient.exc.HTTPInternalServerError: HTTPInternalServerError (HTTP 500) ERROR Value should be one of: alarm, ok, insufficient data

Liusheng (liusheng)
Changed in ceilometer:
assignee: nobody → Liusheng (liusheng)
description: updated
tags: added: alarm
Liusheng (liusheng)
tags: removed: alarm
Eoghan Glynn (eglynn)
description: updated
Changed in ceilometer:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Pradyumna Sampath (pradysam-deactivatedaccount) wrote :

Hi Eoghan et al

We've been looking this bug and here are some comments.

I think there could (should?) be 2 approaches to this
(1) To validate input to python-ceilometerclient to not accept anything else apart from one of the ALARM_STATES (defined in python-ceilometerclient/ceilometerclient/v2/shell.py)
(2) To validate input within ceilometer api code to throw a "BadRequest.." (ceilometer/ceilometer/api/controllers/v2.py) (within the call "_set"

Perhaps its a good idea to do both of the above. Is this a right approach ?

Changed in python-ceilometerclient:
assignee: nobody → Pradyumna Sampath (pradysam)
Changed in ceilometer:
assignee: Liusheng (liusheng) → Pradyumna Sampath (pradysam)
status: Triaged → In Progress
Changed in python-ceilometerclient:
status: New → In Progress
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/132416

Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

why the python-ceilometerclient is affected?

Revision history for this message
Pradyumna Sampath (pradysam-deactivatedaccount) wrote :

The python-ceilometerclient must also validate that alarm_state is one of the three valid states, before the request gets passed over the API.

The reason for this is that the API returns an Invalid Input (assuming that the proposed fix is merged) and that is still not user friendly enough for the CLI user to understand that state has to be one of ['ok','alarm' or 'insufficient data'].

So, I think a client side check is necessary before a request is made over the API.

Example:
$ ceilometer alarm-threshold-create -m instance --threshold 20 --state abc --name test_alarm15oct
Invalid alarm state: abc

The above error being a CommandError exception.

Revision history for this message
Pradyumna Sampath (pradysam-deactivatedaccount) wrote :

Example:
$ ceilometer alarm-threshold-create -m instance --threshold 20 --state abc --name test_alarm15oct
Invalid alarm state: abc, should be one of ['ok','alarm' or 'insufficient data']

Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

just dump the error message from API response

I think there already have a bug/patch for the dump error message issue, but can't find where, I can be wrong, so go ahead

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

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

commit 7cf60e2a3b54b7a763434f65cb045b80074addf1
Author: Pradyumna Sampath <email address hidden>
Date: Thu Nov 20 01:33:33 2014 -0800

    Validate AdvEnum & return an InvalidInput on error

    Raise a relevant exception of InvalidInput while validating if
    the input to AdvEnum is not one of what is expected.

    Closes-bug: #1320430
    Change-Id: I48f014cc09e7d88e9b0f02fb8e9cf45772178b2c

Changed in ceilometer:
status: In Progress → Fix Committed
Eoghan Glynn (eglynn)
Changed in ceilometer:
milestone: none → kilo-1
Eoghan Glynn (eglynn)
tags: added: juno-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (stable/juno)

Fix proposed to branch: stable/juno
Review: https://review.openstack.org/138320

Alan Pevec (apevec)
tags: removed: juno-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ceilometer (stable/juno)

Reviewed: https://review.openstack.org/138320
Committed: https://git.openstack.org/cgit/openstack/ceilometer/commit/?id=37e593eb4df040cce83e9ccf381318e6df2d0faa
Submitter: Jenkins
Branch: stable/juno

commit 37e593eb4df040cce83e9ccf381318e6df2d0faa
Author: Pradyumna Sampath <email address hidden>
Date: Thu Nov 20 01:33:33 2014 -0800

    Validate AdvEnum & return an InvalidInput on error

    Raise a relevant exception of InvalidInput while validating if
    the input to AdvEnum is not one of what is expected.

    Closes-bug: #1320430
    Change-Id: I48f014cc09e7d88e9b0f02fb8e9cf45772178b2c
    (cherry picked from commit 7cf60e2a3b54b7a763434f65cb045b80074addf1)

Thierry Carrez (ttx)
Changed in ceilometer:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: kilo-1 → 2015.1.0
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.