[nailgun] Nailgun returns Internal Server Error 500 with incorrectly specified deployment_history task status request

Bug #1585060 reported by Vitalii Kulanov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Released
High
Fuel Sustaining

Bug Description

Detailed bug description:
Trying to get deployment_history task info with incorrectly specified status leads to 500 Server Error: Internal Server Error.

[root@fuel ~]# fuel deployment-tasks --tid 9 --status pendin --debug
GET http://10.20.0.2:8000/api/v1/transactions/9/deployment_history/?nodes=&statuses=pendin
500 Server Error: Internal Server Error for url: http://10.20.0.2:8000/api/v1/transactions/9/deployment_history/?nodes=&statuses=pendin ((psycopg2.DataError) invalid input value for enum history_task_statuses: "pendin"
LINE 3: ...ry.task_id = '9' AND deployment_history.status IN ('pendin')

[SQL: 'SELECT deployment_history.id AS deployment_history_id, deployment_history.task_id AS deployment_history_task_id, deployment_history.deployment_graph_task_name AS deployment_history_deployment_graph_task_name, deployment_history.node_id AS deployment_history_node_id, deployment_history.time_start AS deployment_history_time_start, deployment_history.time_end AS deployment_history_time_end, deployment_history.status AS deployment_history_status, deployment_history.custom AS deployment_history_custom \nFROM deployment_history \nWHERE deployment_history.task_id = %(task_id_1)s AND deployment_history.status IN (%(status_1)s)'] [parameters: {'task_id_1': u'9', 'status_1': u'pendin'}])

Nailgun logs:
2016-05-24 05:30:00.618 ERROR [7f77beb3f880] (base) Unexpected exception occured
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nailgun/api/v1/handlers/base.py", line 285, in content_json
    resp = func(cls, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/nailgun/api/v1/handlers/deployment_history.py", line 47, in GET
    statuses)
  File "/usr/lib/python2.7/site-packages/nailgun/objects/base.py", line 435, in to_json
    iterable=iterable
  File "/usr/lib/python2.7/site-packages/nailgun/objects/base.py", line 420, in to_list
    return [cls.single.to_dict(o, fields=fields) for o in use_iterable]
  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 1341, in _handle_dbapi_exception
    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, cause=cause)
  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)
DataError: (psycopg2.DataError) invalid input value for enum history_task_statuses: "pendin"
LINE 3: ...ry.task_id = '9' AND deployment_history.status IN ('pendin')
                                                              ^
 [SQL: 'SELECT deployment_history.id AS deployment_history_id, deployment_history.task_id AS deployment_history_task_id, deployment_history.deployment_graph_task_name AS deployment_history_deployment_graph_task_name, deployment_history.node_id AS deployment_history_node_id, deployment_history.time_start AS deployment_history_time_start, deployment_history.time_end AS deployment_history_time_end, deployment_history.status AS deployment_history_status, deployment_history.custom AS deployment_history_custom \nFROM deployment_history \nWHERE deployment_history.task_id = %(task_id_1)s AND deployment_history.status IN (%(status_1)s)'] [parameters: {'task_id_1': u'9', 'status_1': u'pendin'}]

Steps to reproduce:
 1. Deploy Fuel (e.g. 1 master + 3 nodes).
 2. Create env and add several nodes to it.
 3. Deploy environment.
 4. Try to get deployment history tasks (fuelclient/REST API) with nonexistent (incorrect) status:
    fuel deployment-tasks --tid 9 --status pendin --debug (GET http://10.20.0.2:8000/api/v1/transactions/9/deployment_history/?nodes=&statuses=pendin)

Expected results:
 Can be:
 * 400 Response code with detailed error description
 * Return empty result as request don't match any results

Actual result:
 500 Server Error: Internal Server Error

Reproducibility:
 Always

Description of the environment:
cat /etc/fuel_build_id:
 191
cat /etc/fuel_build_number:
 191
cat /etc/fuel_release:
 10.0
cat /etc/fuel_openstack_version:
 newton-10.0

Changed in fuel:
assignee: nobody → Vitalii Kulanov (vitaliy-t)
Changed in fuel:
assignee: Vitalii Kulanov (vitaliy-t) → nobody
Changed in fuel:
milestone: none → 10.0
assignee: nobody → Fuel Sustaining (fuel-sustaining-team)
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Vitalii Kulanov (vitaliy-t) wrote :
Changed in fuel:
status: Confirmed → 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.