Custom actions can cause database errors if they pass the result class objects

Bug #1645295 reported by Dougal Matthews
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mistral
Fix Released
Medium
Dougal Matthews

Bug Description

When a custom Mistral action returns mistral.workflow.utils.Result, it can cause a database error if it passes something other than a string to the class.

For example:

    return Result(error=Exception())

During serialisation this is then converted to an empty dict and it is attempted to be inserted into the database where a string is required. This is an example log line which demonstrates the error:

    2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters [-] DBAPIError exception wrapped from (pymysql.err.ProgrammingError) (1064, u"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '}, processed=1 WHERE task_executions_v2.id = 'e4bb9204-7706-47c6-a742-b29d964c01' at line 1") [SQL: u'UPDATE task_executions_v2 SET updated_at=%(updated_at)s, state=%(state)s, state_info=%(state_info)s, processed=%(processed)s WHERE task_executions_v2.id = %(task_executions_v2_id)s'] [parameters: {'state_info': {}, 'state': 'ERROR', 'processed': 1, 'updated_at': datetime.datetime(2016, 11, 28, 9, 43, 2, 283039), 'task_executions_v2_id': u'e4bb9204-7706-47c6-a742-b29d964c01c3'}]

Note the in the parameters being passed to the SQL - 'state_info': {}

More details to come as I work on this.

Revision history for this message
Dougal Matthews (d0ugal) wrote :
Download full text (18.1 KiB)

Full traceback of the error from the engine log:

2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters [-] DBAPIError exception wrapped from (pymysql.err.ProgrammingError) (1064, u"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '}, processed=1 WHERE task_executions_v2.id = 'e4bb9204-7706-47c6-a742-b29d964c01' at line 1") [SQL: u'UPDATE task_executions_v2 SET updated_at=%(updated_at)s, state=%(state)s, state_info=%(state_info)s, processed=%(processed)s WHERE task_executions_v2.id = %(task_executions_v2_id)s'] [parameters: {'state_info': {}, 'state': 'ERROR', 'processed': 1, 'updated_at': datetime.datetime(2016, 11, 28, 9, 43, 2, 283039), 'task_executions_v2_id': u'e4bb9204-7706-47c6-a742-b29d964c01c3'}]
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters Traceback (most recent call last):
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters context)
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters cursor.execute(statement, parameters)
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters File "/usr/lib/python2.7/site-packages/pymysql/cursors.py", line 166, in execute
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters result = self._query(query)
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters File "/usr/lib/python2.7/site-packages/pymysql/cursors.py", line 322, in _query
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters conn.query(q)
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 841, in query
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters self._affected_rows = self._read_query_result(unbuffered=unbuffered)
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1029, in _read_query_result
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters result.read()
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1312, in read
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters first_packet = self.connection._read_packet()
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 991, in _read_packet
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters packet.check_error()
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy.exc_filters File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 393, in check_error
2016-11-28 09:43:02.283 19586 ERROR oslo_db.sqlalchemy...

Revision history for this message
Dougal Matthews (d0ugal) wrote :

Upgrading this to critical as it can leave you in a broken state with an action being stuck as "RUNNING"

Changed in mistral:
importance: High → Critical
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to mistral (master)

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

Changed in mistral:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on mistral (master)

Change abandoned by Dougal Matthews (<email address hidden>) on branch: master
Review: https://review.openstack.org/407005

Changed in mistral:
milestone: ocata-2 → ocata-3
Dougal Matthews (d0ugal)
Changed in mistral:
importance: Critical → Medium
Changed in mistral:
status: In Progress → 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.