[openstack-dev] Exceptions being translated in projects

John Griffith john.griffith at solidfire.com
Fri May 10 16:39:02 UTC 2013


On Fri, May 10, 2013 at 8:59 AM, Flavio Percoco <flavio at redhat.com> wrote:

> Greetings,
>
> According to our wiki page[0], exceptions shouldn't be translated - which
> I agree
> with - but, there are many exceptions marked for translation throughout
> OpenStack.
>
> I'd like to understand why there's such inconsistency and whether the
> wiki or the code should be changed.
>
> The Issue:
> =========
>
> Lets split exceptions in 2 groups:
>
> 1) The ones raised by OpenStack modules when some conditions are not met,
> quotas exceeded, whatever. For Example:
>         # Nova: quota.py:286
>     if overs:
>         raise exception.OverQuota(overs=**sorted(overs), quotas=quotas,
>                                   usages={})
>
> 2) The ones coming from * that were catched, reformatted and
> re-raised.
>
> I viewed this a bit differently, perhaps incorrectly...  But my logic in
the past has been don't do the translation in the raise, however if we're
adding a LOG output message along with the exception (whether it's in a
catch or otherwise) it seemed that the translation should be there.


That being said, it seems we do have a bit of a mix even in just case 1
(the actual raise itself).  My thought is that the raise should not have
the translation but that any additional LOG call associated with it
should.

I'd agree on translating #1 since they are exceptions that belong to the
> module
> itself and, lets say, it has control over them - even though, there's a
> risk on
> doing that - whereas for #2 it doesn't and at the time of
> catching-and-(reraising|**logging) anything could happen.
>
> Find bellow some cases where #2 is happening.
>
> Nova:
>     https://github.com/openstack/**nova/blob/master/nova/**
> exception.py#L133<https://github.com/openstack/nova/blob/master/nova/exception.py#L133>
>
> Glance:
>     https://github.com/openstack/**glance/blob/master/glance/db/**
> sqlalchemy/api.py#L157<https://github.com/openstack/glance/blob/master/glance/db/sqlalchemy/api.py#L157>
>
> Cinder:
>     https://github.com/openstack/**cinder/blob/master/cinder/**
> volume/drivers/nexenta/volume.**py#L274<https://github.com/openstack/cinder/blob/master/cinder/volume/drivers/nexenta/volume.py#L274>
>
>
> Keystone, instead, doesn't translate exceptions (I couldn't find a case
> in my quick look).
>
> Proposal
> ========
>
> That being said, in order to keep consistency throughout OpenStack in
> terms of
> translations and within the same app wrt "exceptions being translated"
> I want to propose removing translations from exceptions, completely.
> However,
> there could be cases (HTTP Errors?) where translating exceptions could make
> sense and should be fine, or not?
>
> Thoughts? Feedback? Volunteers?
>
> Hopefully, I'm not seeing this from the wrong side, if so, please
> explain and I'll STFU
> Cheers,
> FF
>
>
> [0] https://wiki.openstack.org/**wiki/Translations#What_To_**Translate<https://wiki.openstack.org/wiki/Translations#What_To_Translate>
>
> --
> { name: "Flavio Percoco",
>    gpg: "87112EC1",    internal: "8261386",
>    phone: "+390687502386",
>    irc: ["fpercoco", "flaper87"]}
>
> ______________________________**_________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.**org <OpenStack-dev at lists.openstack.org>
> http://lists.openstack.org/**cgi-bin/mailman/listinfo/**openstack-dev<http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130510/0058cc80/attachment.html>


More information about the OpenStack-dev mailing list