i18n - Terminating instance with invalid instance id causes error in the response

Bug #699654 reported by Tushar Patil
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Tushar Patil

Bug Description

When Japanese Locale is used, nova cannot reply UTF-8 error message correctly. Because type-mismatch error between utf-8 and string occurs.

To reproduce this problem, please do following steps.
1.place attached Japanese (utf-8) .mo file to locale directory. path is: /usr/share/locale/ja/LC_MESSAGES/nova.mo
2.execute nova-api daemon with language setting (LANGUAGE=ja_JP.UTF-8).
example:
LANGUAGE=ja_JP.UTF-8 ./nova.sh run
3.execute command. euca-terminate-instance i-noexist
This command should return error response because instance does not exists.

nova-api got error.
root@usv401:/opt/openstack# euca-terminate-instances i-gvmfxw
Warning: failed to parse error message from AWS: <unknown>:1:0: syntax error
BotoServerError: 500 Internal Server Error
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/eventlet/wsgi.py", line 336, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/pymodules/python2.6/routes/middleware.py", line 130, in __call__
    response = self.app(environ, start_response)
  File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/pymodules/python2.6/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/pymodules/python2.6/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/openstack/nova/nova/api/ec2/__init__.py", line 308, in __call__
    return self._error(req, type(ex).__name__, str(ex))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)

I still feel that this patch is not sufficient. There could be couple of more similar issues at other places. For e.g. if the data associated with any of the entity like instance/image contains UTF-8(Multi-byte) data then I think that it will crash while sending the response.

Related branches

Revision history for this message
Tushar Patil (tpatil) wrote :
Revision history for this message
Jay Pipes (jaypipes) wrote :

Patch looks good with exception of leaving a statement commented out. I'll get a fix for this proposed shortly. Thanks, Tushar!

Changed in nova:
assignee: nobody → Jay Pipes (jaypipes)
status: New → In Progress
Revision history for this message
Jay Pipes (jaypipes) wrote :

Tushar, can I ask you for a favor? Could you attach that .mo file to this bug report so I can use it in testing? Thanks much!

Revision history for this message
Tushar Patil (tpatil) wrote :
Revision history for this message
Jay Pipes (jaypipes) wrote :

Thanks, Tushar!

Revision history for this message
Jay Pipes (jaypipes) wrote :

When running ./bin/nova-api with no locale (English locale):

(.nova-venv)jpipes@serialcoder:~/repos/nova/bug699654$ euca-terminate-instances i-noexist
EC2_URL not specified. Trying http://localhost:8773/services/Eucalyptus
Warning: failed to parse error message from AWS: <unknown>:1:0: syntax error
EC2ResponseError: 403 Forbidden
403 Forbidden

Access was denied to this resource.

So, there seems to be an additional bug of the failure to parse error message...

Revision history for this message
Jay Pipes (jaypipes) wrote :

I had to fix nova/wsgi.py to i18n a string in there, and then put that into the translation file, but afterwards, I could not get an error:

jpipes@serialcoder:~/repos/nova/bug699654$ LANGUAGE=ja_JP.UTF-8 ./bin/nova-api
(nova.root 2011.1-LOCALBRANCH:LOCALREVISION): AUDIT [N/A] ./bin/nova-api 上で最低の 0.0.0.0:8774 の
(nova.root 2011.1-LOCALBRANCH:LOCALREVISION): AUDIT [N/A] ./bin/nova-api 上で最低の 0.0.0.0:8773 の
(nova.api 2011.1-LOCALBRANCH:LOCALREVISION): AUDIT [N/A] Authentication Failure: No user for access key jpipes
(nova.api 2011.1-LOCALBRANCH:LOCALREVISION): INFO [N/A] X.Xs 127.0.0.1 GET /Eucalyptus/ None:None 403 [Boto/1.9b (linux2)] text/plain text/html

and in a separate terminal:

jpipes@serialcoder:~/repos/nova/bug699654$ euca-terminate-instances i-noexist
EC2_URL not specified. Trying http://localhost:8773/services/Eucalyptus
Warning: failed to parse error message from AWS: <unknown>:1:0: syntax error
EC2ResponseError: 403 Forbidden
403 Forbidden

Access was denied to this resource.

tried with locale set for euca-terminate-instances:

jpipes@serialcoder:~/repos/nova/bug699654$ LANGUAGE=ja_JP.UTF-8 euca-terminate-instances i-noexist
EC2_URL not specified. Trying http://localhost:8773/services/Eucalyptus
Warning: failed to parse error message from AWS: <unknown>:1:0: syntax error
EC2ResponseError: 403 Forbidden
403 Forbidden

Access was denied to this resource.

This may be because the 403 returned does not trigger any translated strings...still trying to figure out a way of testing this :(

Thierry Carrez (ttx)
Changed in nova:
importance: Undecided → Medium
Revision history for this message
Tushar Patil (tpatil) wrote :

I could reproduce the above problem when I export EC2_URL as empty and provide incorrect EC2_ACCESS_KEY or EC2_SECRET_KEY in novarc.
In this case, nova is returning webob.exc.HTTPForbidden() exception. Do you see any problem in this code? or you are trying to figure out a way to test the fix?

Revision history for this message
Jay Pipes (jaypipes) wrote :

I was just trying to reproduce the original error and figure out a way to test this...still working on it :)

Revision history for this message
Tushar Patil (tpatil) wrote :

I have reported new bug for the log and error messages which are not i18N. Please refer to Bug no https://bugs.launchpad.net/nova/+bug/705186

I have made couple of changes to nova/api/ec2/__init__.py. Please see the attached patch for the fix.

Can you please review it and let me know if it is ready to go in bexar?

Thanks.
Tushar

Revision history for this message
Jay Pipes (jaypipes) wrote :

Cool, yes, I like the patch, Tushar, thanks! Instead of submitting a patch, why not become a full-fledged Nova contributor? :)

Please do the following:

# in your local bzr branch of Nova:
Read http://wiki.openstack.org/HowToContribute and sign the CLA online (link is on that wiki page)
bzr commit --fixes=lp:699654 -m "Fix for LP Bug #699654. Ensure that EC2 API writes exceptions to log using utf8'd arguments"
bzr push lp:~tpatil/nova/bug699654

Then, once you do that, find and click on your branch here: http://code.launchpad.net/nova

Click the "Propose for Merging" link and follow the steps to propose your branch for merging into lp:nova (trunk).

Let me know if you've got any questions on the process, or if you don't want to do it at all. I'm happy to submit the patch, but figured you might want to get your name in the list of Nova authors :)

Cheers!
jay

Changed in nova:
assignee: Jay Pipes (jaypipes) → Tushar Patil (tpatil)
Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → 2011.1
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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