Improve serviceability and usability for API, adding more logs in API layer

Registered by Yang Yu

1. Run below curl command, you will get a message says "An object with the specified identifier was not found".
# curl -i -X GET -H 'X-Auth-Token: d1aafceeb8f14a0da6390a016126c8f3' -H 'Content-Type: application/json' -H 'User-Agent: python-glanceclient' http://127.0.0.1:9292/v2/images/blah
HTTP/1.1 404 Not Found
Content-Length: 187
Content-Type: text/html; charset=UTF-8
X-Openstack-Request-Id: req-e18f9714-f1ae-4d2c-845d-36e04ea9e97a
Date: Wed, 09 Oct 2013 03:38:24 GMT

<html>
 <head>
  <title>404 Not Found</title>
 </head>
 <body>
  <h1>404 Not Found</h1>
  GL-4060EB6 An object with the specified identifier was not found.
 </body>

Actual results: In /var/log/glance/api.log, there is no warning message in log file to tell user about that user action failed, e.g. "An object with the specified identifier was not found."

But for Nova/Cinder/Neutron projects, they also print the exception to the log. Take Cinder as an example,

curl -i http://127.0.0.1:8776/v1/1aaa0b70c70d43318230b926febd0da6/backups/blah -X GET -H "X-Auth-Project-Id: service" -H "User-Agent: python-cinderclient" -H "Accept: application/json" -H "X-Auth-Token: MIIMVwAILMVFDiHoA==" -H "Accept-Language: ja"

HTTP/1.1 404 Not Found
Content-Length: 77
Content-Type: application/json; charset=UTF-8
X-Compute-Request-Id: req-b996b5ab-37d2-4e36-87b5-79a8a7b8be89
Date: Mon, 19 Aug 2013 15:58:59 GMT

{"itemNotFound": {"message": "Backup blah could not be found.", "code": 404}}

Then I can see this message in cinder log:
var/log/cinder/api.log
2013-09-12 21:58:27.080 25419 INFO cinder.api.openstack.wsgi [req-5d8324af-2e3f-41a5-bf20-0a356a568cd0 3f659614c983446aaabdd4d7bdc5ee72 18fc85c8306a4e918b26571ba0b11f79] HTTP exception thrown: Backup blah could not be found.

So in order to improve Glance serviceability and usability, we'd better to keep consistent with other projects.

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
Yang Yu
Direction:
Needs approval
Assignee:
None
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

Gerrit topic: https://review.openstack.org/#q,topic:bp/wsgi-servicablity-api-log,n,z

Addressed by: https://review.openstack.org/52029
    Format the response for glance API exception

This has by accident been partially implemented by https://review.openstack.org/#/c/55787/

I think this could be accepted on the following conditions
- it should not be a *warning* message on simple 4xx errors
- it should not be overly verbose at the INFO level. At the INFO level we should really only have one message per incoming request, for any normal circumstances (2xx, 3xx, 4xx http return codes).
- for backwards compatibility, we should not change the format of the api error responses

For now this looks abandoned.
markwash abandoned 2014-02-18

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.