Hi, all

Openstack APIs interact with each other and external systems partially by
passing of HTTP errors. The only valuable difference between types of
exceptions is HTTP-codes, but current codes are generalized, so external
system can’t distinguish what actually happened.

As an example two different failures below differs only by error message:

request:

POST /v2/790f5693e97a40d38c4d5bfdc45acb09/servers HTTP/1.1

Host: 192.168.122.195:8774

X-Auth-Project-Id: demo

Accept-Encoding: gzip, deflate, compress

Content-Length: 189

Accept: application/json

User-Agent: python-novaclient

X-Auth-Token: 2cfeb9283d784cfba694f3122ef413bf

Content-Type: application/json

{"server": {"name": "demo", "imageRef":
"171c9d7d-3912-4547-b2a5-ea157eb08622", "key_name": "test", "flavorRef":
"42", "max_count": 1, "min_count": 1, "security_groups": [{"name": "bar"}]}}

response:

    HTTP/1.1 400 Bad Request

Content-Length: 118

Content-Type: application/json; charset=UTF-8

X-Compute-Request-Id: req-a995e1fc-7ea4-4305-a7ae-c569169936c0

Date: Fri, 23 Jan 2015 10:43:33 GMT

{"badRequest": {"message": "Security group bar not found for project
790f5693e97a40d38c4d5bfdc45acb09.", "code": 400}}

and

request:

POST /v2/790f5693e97a40d38c4d5bfdc45acb09/servers HTTP/1.1

Host: 192.168.122.195:8774

X-Auth-Project-Id: demo

Accept-Encoding: gzip, deflate, compress

Content-Length: 192

Accept: application/json

User-Agent: python-novaclient

X-Auth-Token: 24c0d30ff76c42e0ae160fa93db8cf71

Content-Type: application/json

{"server": {"name": "demo", "imageRef":
"171c9d7d-3912-4547-b2a5-ea157eb08622", "key_name": "foo", "flavorRef":
"42", "max_count": 1, "min_count": 1, "security_groups": [{"name":
"default"}]}}

response:

HTTP/1.1 400 Bad Request

Content-Length: 70

Content-Type: application/json; charset=UTF-8

X-Compute-Request-Id: req-87604089-7071-40a7-a34b-7bc56d0551f5

Date: Fri, 23 Jan 2015 10:39:43 GMT

{"badRequest": {"message": "Invalid key_name provided.", "code": 400}}

The former specifies an incorrect security group name, and the latter an
incorrect keypair name. And the problem is, that just looking at the
response body and HTTP response code an external system can’t understand
what exactly went wrong. And parsing of error messages here is not the way
we’d like to solve this problem.

Another example for solving this problem is AWS EC2 exception codes [1]

So if we have some service based on Openstack projects it would be useful
to have some concrete error codes(textual or numeric), which could allow to
define what actually goes wrong and later correctly process obtained
exception. These codes should be predefined for each exception, have
documented structure and allow to parse exception correctly in each step of
exception handling.

So I’d like to discuss implementing such codes and its usage in openstack
projects.

[1] -
http://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html
__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to