git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[keystone][placement][neutron][api-sig] http404 to NotFound, or how should a http json error body look like?


Hi,

Recently I planned to add tests to the neutron feature routed provider 
networks, which actually uses placement API to make possible the 
scheduling based on neutron segment information.
I realized that the feature last worked on Queens. We can discuss 
separately the lack of test coverage, and similar things, but I would 
like to narrow or view now.
The neutron bug report, with some background information: 
https://bugs.launchpad.net/neutron/+bug/1828543

After some debugging I realized that the problem comes from the fact 
that at a point neutron uses the information received in http404, like this:
try:
     return self._get(url).json()
except keystoneauth1.exceptions.NotFound as e:
     if 'foo' in e.details:
         do_something()
see: 
https://opendev.org/openstack/neutron-lib/src/branch/master/neutron_lib/placement/client.py#L405-L406

keystoneauth1 expects the http body in case of for example http404 to be 
something like this (python dict comes now):
body= {'error': {'message': 'Foooooo', 'details': 'Baaaaar'}}
see: 
https://opendev.org/openstack/keystoneauth/src/branch/master/keystoneauth1/exceptions/http.py#L406-L415

But placement started to adopt one suggestion from the API-SIG:
http://specs.openstack.org/openstack/api-wg/guidelines/errors.html,

and that is something like this (again python):
body={'errors': [{'status': 404, 'title': 'Not Found', 'detail': 'The 
resource could not be found.... ', 'request_id': '...'}]}

Shall I ask for help how I should make this bug in neutron fixed?
As a quick and dirty solution in neutron I can use the response from the 
exception, but I feel that there should be a better way to fix this:-)

Thanks in advance for the help

Regards
LAjos