Gnocchi dispatcher does not handle resource ids with /

Bug #1500890 reported by Julien Danjou
30
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
Medium
ZhiQiang Fan

Bug Description

If a resource ID contains a / in its name (e.g. 192.168.2.3./dev/vda) the Gnocchi dispatcher does not translate/escape the slash which led to a 405 error.

2015-09-29 15:39:25.183 88793 ERROR ceilometer.dispatcher.gnocchi [-] Fail to post measure on metric hardware.disk.inodes.used of resource 192.168.100.50./dev/mapper/rhel-root with status: 405: <html>
 <head>
  <title>405 Method Not Allowed</title>
 </head>
 <body>
  <h1>405 Method Not Allowed</h1>
  The method POST is not allowed for this resource. <br /><br />

 </body>
</html>

Julien Danjou (jdanjou)
Changed in ceilometer:
status: New → Triaged
importance: Undecided → High
Wenzhi Yu (yuywz)
Changed in ceilometer:
assignee: nobody → Wen Zhi Yu (yuywz)
Revision history for this message
Wenzhi Yu (yuywz) wrote :

Hi Julien,

Sorry I don't understand why resource_id contains '/' will lead to a 405 Error, I found the gnocchi dispatcher will normalize the resource_id in url using urlparse.quote method, see [1]. So the '/' in resource_id will be translated to '%2F'.

[1] https://github.com/openstack/ceilometer/blob/master/ceilometer/dispatcher/gnocchi_client.py#L234

Revision history for this message
Julien Danjou (jdanjou) wrote :

You're right. That might have been fixed in the meantime.

Changed in ceilometer:
status: Triaged → Incomplete
Revision history for this message
gordon chung (chungg) wrote :

this is valid. but i think it's on gnocchi. when i run:

curl -d '{}' http://localhost:8041/v1/resource/swift_account/9ddf9eaa81bd43409e9ce4e77c2cc20b%2Fglance/metric/storage.containers.objects/measures

i'll get a 405 error and debugging, 9ddf9eaa81bd43409e9ce4e77c2cc20b%2Fglance gives the uuid as one path, and 'glance' as another

affects: ceilometer → gnocchi
Changed in gnocchi:
status: Incomplete → Triaged
Revision history for this message
Julien Danjou (jdanjou) wrote :

That might be actually on Pecan.

Revision history for this message
Chris Dent (cdent) wrote :

Or it could be the web server being used. Handling of %2F is notoriously painful. Some servers will explicitly manipulate it in PATH_INFO so that it goes back to '/' before getting to the WSGI app.

Which is _really_ annoying. Here's an example from my past: https://github.com/tiddlyweb/tiddlyweb/blob/master/tiddlyweb/web/serve.py#L119

See also: http://httpd.apache.org/docs/current/mod/core.html#allowencodedslashes (which frequently doesn't actually work).

Revision history for this message
gordon chung (chungg) wrote :

yeah... when using _lookup, it seems to specifically split on '/'[1]... or it could be what cdent mentioned... so basically this might be back on ceilometer.

[1] http://pecan.readthedocs.org/en/latest/routing.html#routing-to-subcontrollers-with-lookup

ZhiQiang Fan (aji-zqfan)
Changed in ceilometer:
status: New → Triaged
ZhiQiang Fan (aji-zqfan)
Changed in ceilometer:
assignee: nobody → ZhiQiang Fan (aji-zqfan)
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/237730

Julien Danjou (jdanjou)
no longer affects: gnocchi
gordon chung (chungg)
Changed in ceilometer:
assignee: ZhiQiang Fan (aji-zqfan) → nobody
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ceilometer (master)

Reviewed: https://review.openstack.org/237730
Committed: https://git.openstack.org/cgit/openstack/ceilometer/commit/?id=44d57696ecb4200605161115b5d2e7114961a747
Submitter: Jenkins
Branch: master

commit 44d57696ecb4200605161115b5d2e7114961a747
Author: ZhiQiang Fan <email address hidden>
Date: Tue Oct 20 12:25:23 2015 -0600

    unquote resource id to support slash in it

    Swift related meters can generate samples with special resource id
    which contains slash, such as: 29f809d9-88bb-4c40-b1ba-a77a1fcf8ceb/glance.
    If we query such resource directly, pecan will return 404 error,
    but even end user encodes that special slash, we cannot response too.

    This patch unquotes resource id in case it contains special characters.

    Note that end user needs to use %252F to escape % character as well
    to avoid pecan map slash to path delimiter.

    Change-Id: I744b100524f19fabcc9fa68082c4cd235ca8445f
    Close-Bug: #1500890

ZhiQiang Fan (aji-zqfan)
Changed in ceilometer:
status: Triaged → Fix Released
assignee: nobody → ZhiQiang Fan (aji-zqfan)
importance: Undecided → Medium
milestone: none → mitaka-1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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