nova-manage create/admin functions doesn't check if objects already exists in database

Bug #714245 reported by Christian Berendt
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Wishlist
Unassigned

Bug Description

# nova-manage user create foobar
2011-02-06 21:45:53,701 AUDIT nova.auth.manager [-] Created user foobar (admin: False)
export EC2_ACCESS_KEY=72073076-19eb-4112-adf9-ae4e0e67b8be
export EC2_SECRET_KEY=0446720c-cb2e-43e0-aae7-27f4aa6af47b

# nova-manage user create foobar
2011-02-06 21:45:55,567 ERROR nova.exception [-] DB exception wrapped
(nova.exception): TRACE: Traceback (most recent call last):
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/nova/exception.py", line 105, in _wrap
(nova.exception): TRACE: return f(*args, **kwargs)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/session.py", line 1397, in flush
(nova.exception): TRACE: self._flush(objects)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/session.py", line 1478, in _flush
(nova.exception): TRACE: flush_context.execute()
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/unitofwork.py", line 304, in execute
(nova.exception): TRACE: rec.execute(self)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/unitofwork.py", line 448, in execute
(nova.exception): TRACE: uow
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/mapper.py", line 1872, in _save_obj
(nova.exception): TRACE: execute(statement, params)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1191, in execute
(nova.exception): TRACE: params)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1271, in _execute_clauseelement
(nova.exception): TRACE: return self.__execute_context(context)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1302, in __execute_context
(nova.exception): TRACE: context.parameters[0], context=context)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1401, in _cursor_execute
(nova.exception): TRACE: context)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1394, in _cursor_execute
(nova.exception): TRACE: context)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/default.py", line 299, in do_execute
(nova.exception): TRACE: cursor.execute(statement, parameters)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 166, in execute
(nova.exception): TRACE: self.errorhandler(self, exc, value)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 35, in defaulterrorhandler
(nova.exception): TRACE: raise errorclass, errorvalue
(nova.exception): TRACE: IntegrityError: (IntegrityError) (1062, "Duplicate entry 'foobar' for key 1") 'INSERT INTO users (created_at, updated_at, deleted_at, deleted, id, name, access_key, secret_key, is_admin) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)' (datetime.datetime(2011, 2, 6, 20, 45, 55, 567009), None, None, False, 'foobar', None, '1462bfea-d3f0-43fe-996b-70360fdfae6c', '0158e6cf-b1aa-4971-993e-09d09c9e493a', False)
(nova.exception): TRACE:
(IntegrityError) (1062, "Duplicate entry 'foobar' for key 1") 'INSERT INTO users (created_at, updated_at, deleted_at, deleted, id, name, access_key, secret_key, is_admin) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)' (datetime.datetime(2011, 2, 6, 20, 45, 55, 567009), None, None, False, 'foobar', None, '1462bfea-d3f0-43fe-996b-70360fdfae6c', '0158e6cf-b1aa-4971-993e-09d09c9e493a', False)
The above error may show that the database has not been created.
Please create a database using nova-manage sync db before running this command.

# nova-manage user admin narf
2011-02-06 21:46:52,737 AUDIT nova.auth.manager [-] Created user narf (admin: True)
export EC2_ACCESS_KEY=e1d4ec61-7436-490f-a052-87ea728a3802
export EC2_SECRET_KEY=6acd167a-9594-43bb-952c-3bf1e3a7a7bd

# nova-manage user admin narf
2011-02-06 21:46:54,428 ERROR nova.exception [-] DB exception wrapped
(nova.exception): TRACE: Traceback (most recent call last):
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/nova/exception.py", line 105, in _wrap
(nova.exception): TRACE: return f(*args, **kwargs)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/session.py", line 1397, in flush
(nova.exception): TRACE: self._flush(objects)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/session.py", line 1478, in _flush
(nova.exception): TRACE: flush_context.execute()
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/unitofwork.py", line 304, in execute
(nova.exception): TRACE: rec.execute(self)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/unitofwork.py", line 448, in execute
(nova.exception): TRACE: uow
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/mapper.py", line 1872, in _save_obj
(nova.exception): TRACE: execute(statement, params)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1191, in execute
(nova.exception): TRACE: params)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1271, in _execute_clauseelement
(nova.exception): TRACE: return self.__execute_context(context)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1302, in __execute_context
(nova.exception): TRACE: context.parameters[0], context=context)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1401, in _cursor_execute
(nova.exception): TRACE: context)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1394, in _cursor_execute
(nova.exception): TRACE: context)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/default.py", line 299, in do_execute
(nova.exception): TRACE: cursor.execute(statement, parameters)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 166, in execute
(nova.exception): TRACE: self.errorhandler(self, exc, value)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 35, in defaulterrorhandler
(nova.exception): TRACE: raise errorclass, errorvalue
(nova.exception): TRACE: IntegrityError: (IntegrityError) (1062, "Duplicate entry 'narf' for key 1") 'INSERT INTO users (created_at, updated_at, deleted_at, deleted, id, name, access_key, secret_key, is_admin) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)' (datetime.datetime(2011, 2, 6, 20, 46, 54, 427439), None, None, False, 'narf', None, '644eefb1-aed9-4403-b318-b4c9a8d7aa28', 'f00c6501-65f8-4c04-91ae-915aadfd6893', True)
(nova.exception): TRACE:
(IntegrityError) (1062, "Duplicate entry 'narf' for key 1") 'INSERT INTO users (created_at, updated_at, deleted_at, deleted, id, name, access_key, secret_key, is_admin) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)' (datetime.datetime(2011, 2, 6, 20, 46, 54, 427439), None, None, False, 'narf', None, '644eefb1-aed9-4403-b318-b4c9a8d7aa28', 'f00c6501-65f8-4c04-91ae-915aadfd6893', True)
The above error may show that the database has not been created.
Please create a database using nova-manage sync db before running this command.

Revision history for this message
Christian Berendt (berendt) wrote :
Download full text (5.2 KiB)

Looks like the other create functions in nova-manage doesn't check for existing entries, too. Please check all create functions.

# nova-manage project create testing admin
2011-02-06 21:50:21,181 ERROR nova.exception [-] DB exception wrapped
(nova.exception): TRACE: Traceback (most recent call last):
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/nova/exception.py", line 105, in _wrap
(nova.exception): TRACE: return f(*args, **kwargs)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/session.py", line 1397, in flush
(nova.exception): TRACE: self._flush(objects)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/session.py", line 1478, in _flush
(nova.exception): TRACE: flush_context.execute()
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/unitofwork.py", line 304, in execute
(nova.exception): TRACE: rec.execute(self)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/unitofwork.py", line 448, in execute
(nova.exception): TRACE: uow
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/mapper.py", line 1872, in _save_obj
(nova.exception): TRACE: execute(statement, params)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1191, in execute
(nova.exception): TRACE: params)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1271, in _execute_clauseelement
(nova.exception): TRACE: return self.__execute_context(context)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1302, in __execute_context
(nova.exception): TRACE: context.parameters[0], context=context)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1401, in _cursor_execute
(nova.exception): TRACE: context)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/base.py", line 1394, in _cursor_execute
(nova.exception): TRACE: context)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/sqlalchemy/engine/default.py", line 299, in do_execute
(nova.exception): TRACE: cursor.execute(statement, parameters)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 166, in execute
(nova.exception): TRACE: self.errorhandler(self, exc, value)
(nova.exception): TRACE: File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 35, in defaulterrorhandler
(nova.exception): TRACE: raise errorclass, errorvalue
(nova.exception): TRACE: IntegrityError: (IntegrityError) (1062, "Duplicate entry 'testing' for key 1") 'INSERT INTO projects (created_at, updated_at, deleted_at, deleted, id, name, description, project_manager) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)' (datetime.datetime(2011, 2, 6, 20, 50, 21, 180352), None, None, False, 'testing', 'testing', 'testing', 'admin')
(nova.exception): TRACE:
2011-02-06 21:50:21,186 CRITICAL nova.root [-] (IntegrityError) (1062, "Duplicate e...

Read more...

summary: - nova-manage user create/admin doesn't check if user already exists
+ nova-manage create/admin functions doesn't check if objects already
+ exists in database
Revision history for this message
Thierry Carrez (ttx) wrote :

Right, nova-manage is a bit raw. It's just a bit more functional than a raw SQL calln and could definitely see some extra user-friendliness...

Changed in nova:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Harshavardhana (harsha-gluster) wrote :

Attaching a proposed patch for this bug. Let me know if this fits well, i can change it if needed.

Changed in nova:
status: Confirmed → In Progress
Thierry Carrez (ttx)
Changed in nova:
status: In Progress → Triaged
Revision history for this message
Thierry Carrez (ttx) wrote :

For the curious people (i.e why did this go to "Triaged" instead of "FixCommitted") is that with an attached patch, the bug has everything needed to be solved ("Triaged") but still needs someone to push it through the process (branch, apply patch, propose patch for merging, fix it if reviews ask for it, etc.).

That someone should consider the bug "In progress" while he is doing it and push it to "Fix committed" when done.

Revision history for this message
Thierry Carrez (ttx) wrote :

@Harshavardhana: would you be interested in proposing your patch as a branch merge proposal (and become one of Nova's authors if the patch ends up accepted ?)

Revision history for this message
Christian Berendt (berendt) wrote :

closing as invalid. this one is very old and bin/nova-manage will probably be removed in the next months. nearly all functionality is now available in python-novaclient.

Changed in nova:
status: Triaged → 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.