← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1603728] Re: search with error regex causes a 500 error

 

Reviewed:  https://review.openstack.org/344945
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=d01695886f3fb6ec1ffe4204e7f4bc72737992cf
Submitter: Jenkins
Branch:    master

commit d01695886f3fb6ec1ffe4204e7f4bc72737992cf
Author: Anton Kremenetsky <anton.kremenetsky@xxxxxxxxx>
Date:   Wed Jul 20 13:24:43 2016 -0400

    Add server name verification in instance search
    
    There are Nova API calls that can accept a server name
    as a regex parameter. For example, if the command
    'nova list --name <some_pattern>' is invoked with
    an incorrect value of the pattern, the nova-api makes
    a request to database and returns Http 500 error. Seems
    it's not convenient.
    
    This fix checks the pattern. If it isn't correct,
    the nova-api returns error 400 with a prompt of a bad regex.
    
    Change-Id: Iad63c668d09ec6a82ace29700fb4949c1acfbe1c
    Closes-Bug: #1603728


** Changed in: nova
       Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1603728

Title:
  search with error regex causes a 500 error

Status in OpenStack Compute (nova):
  Fix Released

Bug description:
  Description
  ===========
  When I search instance with a wrong regx, such as '+', nova-api will return a 500 error.

  Steps to reproduce
  ==================
  nova list --name +

  Expected result
  ===============
  After the execution of the steps above, We can get a prompt of regx error message.

  
  Actual result
  =============
  ERROR (ClientException): Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.
  <class 'oslo_db.exception.DBError'> (HTTP 500) (Request-ID: req-f6a78623-4db5-4f5b-94b1-8edb281b5e7a)

  There are the nova-api.log:
   Traceback (most recent call last):
     File "/usr/lib/python2.7/site-packages/nova/api/openstack/extensions.py", line 478, in wrapped
       return f(*args, **kwargs)
     File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/servers.py", line 294, in detail
       servers = self._get_servers(req, is_detail=True)
     File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/servers.py", line 409, in _get_servers
       sort_keys=sort_keys, sort_dirs=sort_dirs)
     File "/usr/lib/python2.7/site-packages/nova/compute/api.py", line 2128, in get_all
       sort_keys=sort_keys, sort_dirs=sort_dirs)
     File "/usr/lib/python2.7/site-packages/nova/compute/api.py", line 2178, in _get_instances_by_filters
       expected_attrs=fields, sort_keys=sort_keys, sort_dirs=sort_dirs)
     File "/usr/lib/python2.7/site-packages/oslo_versionedobjects/base.py", line 181, in wrapper
       result = fn(cls, context, *args, **kwargs)
     File "/usr/lib/python2.7/site-packages/nova/objects/instance.py", line 1065, in get_by_filters
       use_slave=use_slave, sort_keys=sort_keys, sort_dirs=sort_dirs)
     File "/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/api.py", line 285, in wrapper
       return f(*args, **kwargs)
     File "/usr/lib/python2.7/site-packages/nova/objects/instance.py", line 1049, in _get_by_filters_impl
       sort_keys=sort_keys, sort_dirs=sort_dirs)
     File "/usr/lib/python2.7/site-packages/nova/db/api.py", line 734, in instance_get_all_by_filters_sort
       sort_dirs=sort_dirs)
     File "/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/api.py", line 229, in wrapper
       return f(*args, **kwargs)
     File "/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/api.py", line 330, in wrapped
       return f(context, *args, **kwargs)
     File "/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/api.py", line 2308, in instance_get_all_by_filters_sort
       return _instances_fill_metadata(context, query_prefix.all(), manual_joins)
     File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 2588, in all
       return list(self)
     File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 2736, in __iter__
       return self._execute_and_instances(context)
     File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 2751, in _execute_and_instances
       result = conn.execute(querycontext.statement, self._params)
     File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 914, in execute
       return meth(self, multiparams, params)
     File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
       return connection._execute_clauseelement(self, multiparams, params)
     File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
       compiled_sql, distilled_params
     File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
       context)
     File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1337, in _handle_dbapi_exception
       util.raise_from_cause(newraise, exc_info)
     File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/compat.py", line 200, in raise_from_cause
       reraise(type(exception), exception, tb=exc_tb)
     File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
       context)
     File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
       cursor.execute(statement, parameters)
     File "/usr/lib/python2.7/site-packages/pymysql/cursors.py", line 146, in execute
       result = self._query(query)
     File "/usr/lib/python2.7/site-packages/pymysql/cursors.py", line 296, in _query
       conn.query(q)
     File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 781, in query
       self._affected_rows = self._read_query_result(unbuffered=unbuffered)
     File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 942, in _read_query_result
       result.read()
     File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1138, in read
       first_packet = self.connection._read_packet()
     File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 906, in _read_packet
       packet.check_error()
     File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 367, in check_error
       err.raise_mysql_exception(self._data)
     File "/usr/lib/python2.7/site-packages/pymysql/err.py", line 120, in raise_mysql_exception
       _check_mysql_exception(errinfo)
     File "/usr/lib/python2.7/site-packages/pymysql/err.py", line 115, in _check_mysql_exception
       raise InternalError(errno, errorvalue)

  DBError: (pymysql.err.InternalError) (1139, u"Got error 'nothing to
  repeat at offset 0' from regexp")

  Environment
  ===========
  openstack-nova-api-13.1.0-1.el7.noarch
  Libvirt + KVM

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1603728/+subscriptions


References