Failed to create queue with body {} on sqlalchemy control plane

Bug #1518060 reported by Feilong Wang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
zaqar
Fix Released
Low
Feilong Wang

Bug Description

When using sqlalchemy as control plane, (in my case, i'm using sqlite), if user give the queue body with {}, then zaqar will raise below exception. That because line https://github.com/openstack/zaqar/blob/master/zaqar/storage/pooling.py#L190 will return {} as the flavor name instead of None.

2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues [(None,) 888cbb7064144ae0bce0839165043b01 4a762062f9634145bce08352afb79429 - - -] [project_id:4a762062f9634145bce08352afb79429] (pysqlite2.dbapi2.InterfaceError) Error binding parameter 0 - probably unsupported type. [SQL: u'SELECT "Flavors".name, "Flavors".project, "Flavors".pool, "Flavors".capabilities \nFROM "Flavors" \nWHERE "Flavors".name = ? AND "Flavors".project = ?'] [parameters: ({}, u'4a762062f9634145bce08352afb79429')]
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues Traceback (most recent call last):
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/home/feilong/MyWorkspace/workspace_community/zaqar/zaqar/transport/wsgi/v2_0/queues.py", line 79, in on_put
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues project=project_id)
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/home/feilong/MyWorkspace/workspace_community/zaqar/zaqar/common/pipeline.py", line 97, in consumer
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues tmp = target(*args, **kwargs)
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/home/feilong/MyWorkspace/workspace_community/zaqar/zaqar/storage/base.py", line 370, in create
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues return self._create(name, metadata, project)
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/home/feilong/MyWorkspace/workspace_community/zaqar/zaqar/storage/pooling.py", line 193, in _create
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues self._pool_catalog.register(name, project=project, flavor=flavor)
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/home/feilong/MyWorkspace/workspace_community/zaqar/zaqar/storage/pooling.py", line 492, in register
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues flavor = self._flavor_ctrl.get(flavor, project=project)
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/home/feilong/MyWorkspace/workspace_community/zaqar/zaqar/storage/sqlalchemy/utils.py", line 44, in wrapper
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues return func(*args, **kwargs)
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/home/feilong/MyWorkspace/workspace_community/zaqar/zaqar/storage/sqlalchemy/flavors.py", line 68, in get
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues flavor = self.driver.connection.execute(stmt).fetchone()
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 914, in execute
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues return meth(self, multiparams, params)
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues return connection._execute_clauseelement(self, multiparams, params)
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues compiled_sql, distilled_params
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues context)
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues exc_info
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues reraise(type(exception), exception, tb=exc_tb)
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues context)
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 450, in do_execute
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues cursor.execute(statement, parameters)
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues InterfaceError: (pysqlite2.dbapi2.InterfaceError) Error binding parameter 0 - probably unsupported type. [SQL: u'SELECT "Flavors".name, "Flavors".project, "Flavors".pool, "Flavors".capabilities \nFROM "Flavors" \nWHERE "Flavors".name = ? AND "Flavors".project = ?'] [parameters: ({}, u'4a762062f9634145bce08352afb79429')]
2015-11-20 09:18:13.234 31466 ERROR zaqar.transport.wsgi.v2_0.queues

Feilong Wang (flwang)
Changed in zaqar:
status: New → Triaged
importance: Undecided → Low
assignee: nobody → Fei Long Wang (flwang)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to zaqar (master)

Fix proposed to branch: master
Review: https://review.openstack.org/247867

Changed in zaqar:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to zaqar (master)

Reviewed: https://review.openstack.org/247867
Committed: https://git.openstack.org/cgit/openstack/zaqar/commit/?id=42cb8dd23392daeeaa6637bfe67fc24cc368db8b
Submitter: Jenkins
Branch: master

commit 42cb8dd23392daeeaa6637bfe67fc24cc368db8b
Author: Fei Long Wang <email address hidden>
Date: Fri Nov 20 10:24:35 2015 +1300

    Fix queue create failure when metadata is {}

    When user pass in {} as the PUT body, below code will take {} as
    the flavor name. It's not correct.

    flavor = metadata and metadata.get('_flavor', None)

    This patch fixes it and add an unit test case for that.

    Closes-Bug: #1518060

    Depends-On: Ibd1f72ad95515cbfbaef217677c7230662552661
    Change-Id: I20b69c99c4e8a44c752006024bc56f5b4cc2336a

Changed in zaqar:
status: In Progress → Fix Released
Revision history for this message
Thierry Carrez (ttx) wrote : Fix included in openstack/zaqar 2.0.0.0b2

This issue was fixed in the openstack/zaqar 2.0.0.0b2 development milestone.

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.