500 Server Error when upload graph which already exists in the database

Bug #1648786 reported by TatyanaGladysheva
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Committed
High
Alexander Kislitsky
Mitaka
Fix Released
High
Alexey Shtokolov
Newton
Fix Released
High
Alexey Shtokolov
Ocata
Fix Committed
High
Alexander Kislitsky

Bug Description

Steps to reproduce:
1) Add this commit to the Fuel master node: https://review.openstack.org/#/c/370080/, which helps to add default graphs sequence.
2) Execute 'ln -sf /etc/puppet/modules /etc/fuel/graphs/deploy'
3) ./upload-default-sequence.sh

Actual results:
Script is failed:
[root@nailgun files]# ./upload-default-sequence.sh
Deployment graph was successfully uploaded.
500 Server Error: Internal Server Error for url: http://10.109.0.2:8000/api/v1/releases/2/deployment_graphs/deploy (Unexpected exception, please check logs)

From separate run:
[root@nailgun ~]# fuel2 graph upload -r2 -t deploy -d /etc/fuel/graphs/deploy
500 Server Error: Internal Server Error for url: http://10.109.0.2:8000/api/v1/releases/2/deployment_graphs/deploy (Unexpected exception, please check logs)

From /var/log/nailgun/app.log:
2016-12-09 09:58:03.270 ERROR [7f77247fa880] (deployment_graph) POST failed: (psycopg2.IntegrityError) duplicate key value violates unique constraint "_task_name_deployment_graph_id_uc"
DETAIL: Key (deployment_graph_id, task_name)=(13, pre_deployment_start) already exists.
[SQL: 'INSERT INTO deployment_graph_tasks (deployment_graph_id, task_name, version, condition, type, groups, tasks, roles, reexecute_on, refresh_on, required_for, requires, cross_depended_by, cross_depends, parameters, _custom) VALUES (%(deployment_graph_id)s, %(task_name)s, %(version)s, %(condition)s, %(type)s, %(groups)s, %(tasks)s, %(roles)s, %(reexecute_on)s, %(refresh_on)s, %(required_for)s, %(requires)s, %(cross_depended_by)s, %(cross_depends)s, %(parameters)s, %(_custom)s) RETURNING deployment_graph_tasks.id'] [parameters: {'reexecute_on': [], 'tasks': [], 'groups': [], 'roles': [], 'type': u'stage', 'cross_depended_by': '[]', 'refresh_on': [], 'required_for': [], 'version': '1.0.0', 'task_name': u'pre_deployment_start', 'deployment_graph_id': 13, 'parameters': '{}', 'requires': [], 'cross_depends': '[]', 'condition': None, '_custom': '{}'}]
Traceback (most recent call last):
 File "/usr/lib/python2.7/site-packages/nailgun/api/v1/handlers/deployment_graph.py", line 96, in POST
   data, obj, graph_type=graph_type)
 File "/usr/lib/python2.7/site-packages/nailgun/objects/deployment_graph.py", line 179, in create_for_model
   graph = cls.create(data)
 File "/usr/lib/python2.7/site-packages/nailgun/objects/deployment_graph.py", line 124, in create
   db().flush()
 File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 2019, in flush
   self._flush(objects)
 File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 2137, in _flush
   transaction.rollback(_capture_exception=True)
 File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
   compat.reraise(exc_type, exc_value, exc_tb)
 File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 2101, in _flush
   flush_context.execute()
 File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 373, in execute
   rec.execute(self)
 File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 532, in execute
   uow
 File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 174, in save_obj
   mapper, table, insert)
 File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 800, in _emit_insert_statements
   execute(statement, 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)
IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint "_task_name_deployment_graph_id_uc"
DETAIL: Key (deployment_graph_id, task_name)=(13, pre_deployment_start) already exists

Reproducibility:
Reproducible on 9.2 snapshot #604.

Additional information:
These patches are required for upload-default-sequence.sh, I've added manually before launching of script:
https://review.openstack.org/#/c/370076/
https://review.openstack.org/#/c/370082/
https://review.openstack.org/#/c/370085/

Changed in fuel:
milestone: none → 9.2
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Fuel Sustaining (fuel-sustaining-team)
Revision history for this message
TatyanaGladysheva (tgladysheva) wrote :

This bug appears during verification of bug https://bugs.launchpad.net/fuel/+bug/1643143, verification of bug #1643143 is completely blocked by this bug, so I should move bug to Confirmed status. We need the fix of the current bug.

Revision history for this message
TatyanaGladysheva (tgladysheva) wrote :

Small addition: Comment # 1 is for version 9.2.

Anton Matveev (amatveev)
tags: added: customer-found sla1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to fuel-web (master)

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

Changed in fuel:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to fuel-web (stable/newton)

Fix proposed to branch: stable/newton
Review: https://review.openstack.org/415203

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to fuel-web (stable/mitaka)

Fix proposed to branch: stable/mitaka
Review: https://review.openstack.org/415204

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to fuel-web (master)

Reviewed: https://review.openstack.org/411213
Committed: https://git.openstack.org/cgit/openstack/fuel-web/commit/?id=8031c5eae7a1272e7b2583be34ed3242edbaf4d1
Submitter: Jenkins
Branch: master

commit 8031c5eae7a1272e7b2583be34ed3242edbaf4d1
Author: Alexander Kislitsky <email address hidden>
Date: Thu Dec 15 13:16:32 2016 +0300

    Checking of tasks duplicates added to graph handler

    The exception is raised if we try to save tasks duplicates to the
    graph.

    Change-Id: I315ff82cf51c27de893a514245cf254504ffaaeb
    Closes-Bug: #1648786

Changed in fuel:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to fuel-web (stable/newton)

Reviewed: https://review.openstack.org/415203
Committed: https://git.openstack.org/cgit/openstack/fuel-web/commit/?id=63becb26790a9d911de3f2845152f72e4505a910
Submitter: Jenkins
Branch: stable/newton

commit 63becb26790a9d911de3f2845152f72e4505a910
Author: Alexander Kislitsky <email address hidden>
Date: Thu Dec 15 13:16:32 2016 +0300

    Checking of tasks duplicates added to graph handler

    The exception is raised if we try to save tasks duplicates to the
    graph.

    Change-Id: I315ff82cf51c27de893a514245cf254504ffaaeb
    Closes-Bug: #1648786

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to fuel-web (stable/mitaka)

Reviewed: https://review.openstack.org/415204
Committed: https://git.openstack.org/cgit/openstack/fuel-web/commit/?id=7628c0e51bd27f2664010b45ea3a346a735dcc57
Submitter: Jenkins
Branch: stable/mitaka

commit 7628c0e51bd27f2664010b45ea3a346a735dcc57
Author: Alexander Kislitsky <email address hidden>
Date: Thu Dec 15 13:16:32 2016 +0300

    Checking of tasks duplicates added to graph handler

    The exception is raised if we try to save tasks duplicates to the
    graph.

    Change-Id: I315ff82cf51c27de893a514245cf254504ffaaeb
    Closes-Bug: #1648786

tags: added: on-verification
Revision history for this message
TatyanaGladysheva (tgladysheva) wrote :

Verified on 9.2 snapshot #693.

Actual results:
[root@nailgun files]# ./upload-default-sequence.sh
Deployment graph was successfully uploaded.
Deployment graph was successfully uploaded.
Deployment graph was successfully uploaded.
Deployment graph was successfully uploaded.
Sequence was successfully created:
+------------+----------------+
| Field | Value |
+------------+----------------+
| id | 1 |
| release_id | 2 |
| name | deploy-changes |
+------------+----------------+
Deployment graph was successfully uploaded.
Deployment graph was successfully uploaded.
Deployment graph was successfully uploaded.
Deployment graph was successfully uploaded.
Sequence was successfully created:
+------------+----------------+
| Field | Value |
+------------+----------------+
| id | 2 |
| release_id | 3 |
| name | deploy-changes |
+------------+----------------+
[root@nailgun files]# fuel2 sequence list -e 2
+----+------------+----------------+
| id | release_id | name |
+----+------------+----------------+
| 1 | 2 | deploy-changes |
+----+------------+----------------+
[root@nailgun files]# fuel2 sequence show 1
+------------+-----------------------------------------------+
| Field | Value |
+------------+-----------------------------------------------+
| id | 1 |
| release_id | 2 |
| name | deploy-changes |
| graphs | net-verification, deletion, provision, deploy |
+------------+-----------------------------------------------+

tags: removed: on-verification
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/fuel-web 11.0.0.0rc1

This issue was fixed in the openstack/fuel-web 11.0.0.0rc1 release candidate.

Revision history for this message
Dmitry Belyaninov (dbelyaninov) wrote :

Verified on Newton #1556 iso.

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.