[nailgun] Nailgun returns Internal Server Error 500 while trying to update tag with already existing 'tag' value

Bug #1638191 reported by Vitalii Kulanov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Invalid
High
Alexander Kislitsky
Nominated for Ocata by Oleksiy Molchanov
Mitaka
Invalid
High
Fuel Sustaining
Newton
Invalid
High
Fuel Sustaining

Bug Description

Detailed bug description:
If we try to update some newly created user defined tags with already existing 'tag' value Nailgun returns '500 Server Error: Internal Server Error':

[root@fuel ~]# fuel2 tag update --file_path test_tag.json -t 47
500 Server Error: Internal Server Error for url: http://10.20.0.2:8000/api/v1/tags/47/ (Unexpected exception, please check logs)

Here is a log for Nailgun:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nailgun/api/v1/handlers/base.py", line 298, in handle_errors
    return func(cls, *args, **kwargs)
  File "<string>", line 2, in PUT
  File "/usr/lib/python2.7/site-packages/nailgun/api/v1/handlers/base.py", line 356, in validate
    return func(cls, *args, **kwargs)
  File "<string>", line 2, in PUT
  File "/usr/lib/python2.7/site-packages/nailgun/api/v1/handlers/base.py", line 382, in serialize
    resp = func(cls, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/nailgun/api/v1/handlers/base.py", line 423, in PUT
    self.single.update(obj, data)
  File "/usr/lib/python2.7/site-packages/nailgun/objects/base.py", line 97, in update
    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 170, in save_obj
    mapper, table, update)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 706, in _emit_update_statements
    execute(statement, multiparams)
  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 "__tag_owner_uc"
DETAIL: Key (owner_type, owner_id, tag)=(cluster, 1, test_tag_2) already exists.
 [SQL: 'UPDATE tags SET tag=%(tag)s WHERE tags.id = %(tags_id)s'] [parameters: {'tags_id': 47, 'tag': u'test_tag_2'}]

Steps to reproduce:
1. Deploy Fuel (e.g. 1 master + 5 nodes).
2. Create new env.
3. Create several tags for this environment.
[root@fuel ~]# cat test_tag_1.json
{
    "tag": "test_tag_1",
    "has_primary": false
}
[root@fuel ~]# cat test_tag_2.json
{
    "tag": "test_tag_2",
    "has_primary": false
}
[root@fuel ~]# fuel2 tag list -e 1
+----+------------+-------------+
| id | tag | has_primary |
+----+------------+-------------+
| 47 | test_tag_1 | False |
| 48 | test_tag_2 | False |
+----+------------+-------------+
4. Try to update some user-defined tag, i.e. with id=47 with a new data, where 'tag' value is already defined for some other tags:
[root@fuel ~]# cat test_tag_2.json
{
    "tag": "test_tag_2",
    "has_primary": false
}
[root@fuel ~]# fuel2 tag update --file_path test_tag_2.json -t 47
500 Server Error: Internal Server Error for url: http://10.20.0.2:8000/api/v1/tags/47/ (Unexpected exception, please check logs)
[root@fuel ~]#

Expected results:
Some message that... (Tag 'test_tag_2' is already present.)

Actual result:
500 Server Error: Internal Server Error for url: http://10.20.0.2:8000/api/v1/tags/47/ (Unexpected exception, please check logs)

Reproducibility:
Always

Description of the environment:
[root@fuel ~]# shotgun2 short-report
cat /etc/fuel_build_id:
 859
cat /etc/fuel_build_number:
 859
cat /etc/fuel_release:
 10.0
cat /etc/fuel_openstack_version:
 newton-10.0

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

Folks, I've checked on the master, stable/newton, stable/mitaka, stable/8.0, but we have no table 'tags' for these releases. Could you please provide more details or env with reproduced bug. Marking as incomplete.

Changed in fuel:
status: Confirmed → Incomplete
Revision history for this message
Vitalii Kulanov (vitaliy-t) wrote :

@Alexander, I think that this bug can be marked as Invalid, because it belongs to the first attempt of implementing tags (role-decomposition) by vvalyavskiy that were abandoned and reverted (some links https://review.openstack.org/#/q/327f754d9055005d867b38d60b9b02868ed3549e,n,z). Lately tags support was re-factored. So this bug is not related to new changes and can't be reproduced as well.

Changed in fuel:
status: Incomplete → Invalid
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.