creation of flavors with name of a deleted flavor is not possible

Bug #932867 reported by Christian Berendt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Brian Waldon

Bug Description

it possible to reuse the id of a deleted flavor but it's not possible to create a flavor with the name of a deleted one.

stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create test 100 100 100 100

stack@devstack001:~/devstack$ nova --username admin --password testing flavor-list
+-----+-----------+-----------+------+----------+-------+-------------+
| ID | Name | Memory_MB | Swap | Local_GB | VCPUs | RXTX_Factor |
+-----+-----------+-----------+------+----------+-------+-------------+
| 100 | test | 100 | | 100 | 100 | 1.0 |
| 2 | m1.small | 2048 | | 10 | 1 | 1.0 |
| 3 | m1.medium | 4096 | | 10 | 2 | 1.0 |
| 4 | m1.large | 8192 | | 10 | 4 | 1.0 |
| 5 | m1.xlarge | 16384 | | 10 | 8 | 1.0 |
+-----+-----------+-----------+------+----------+-------+-------------+

stack@devstack001:~/devstack$ nova --username admin --password testing flavor-delete 100

stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create test 100 100 100 100
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)

stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create testtest 100 100 100 100
+-----+----------+-----------+------+----------+-------+-------------+
| ID | Name | Memory_MB | Swap | Local_GB | VCPUs | RXTX_Factor |
+-----+----------+-----------+------+----------+-------+-------------+
| 100 | testtest | 100 | | 100 | 100 | 1 |
+-----+----------+-----------+------+----------+-------+-------------+

stack@devstack001:~/devstack$ nova --username admin --password testing flavor-delete 100

stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create test 100 100 100 100
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)
stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create testtest 100 100 100 100
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)

stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create testtest 101 100 100 100
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)
stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create test 101 100 100 100
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)

this is the stacktrace on nova-api:

2012-02-15 17:26:16,932 ERROR nova.exception [req-7a175400-9aa5-4272-ac17-8fa66ebaf1f3 4599637aa20740d2a59a2621948bcdea 0f0bbc8563a44a6a880c0c1ad85d5e79] DB exception wrapped.
(nova.exception): TRACE: Traceback (most recent call last):
(nova.exception): TRACE: File "/opt/stack/nova/nova/exception.py", line 103, in _wrap
(nova.exception): TRACE: return f(*args, **kwargs)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1400, in flush
(nova.exception): TRACE: self._flush(objects)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1481, in _flush
(nova.exception): TRACE: flush_context.execute()
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 302, in execute
(nova.exception): TRACE: rec.execute(self)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 446, in execute
(nova.exception): TRACE: uow
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/mapper.py", line 1887, in _save_obj
(nova.exception): TRACE: execute(statement, params)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1191, in execute
(nova.exception): TRACE: params)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1271, in _execute_clauseelement
(nova.exception): TRACE: return self.__execute_context(context)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1302, in __execute_context
(nova.exception): TRACE: context.parameters[0], context=context)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1401, in _cursor_execute
(nova.exception): TRACE: context)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1394, in _cursor_execute
(nova.exception): TRACE: context)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 299, in do_execute
(nova.exception): TRACE: cursor.execute(statement, parameters)
(nova.exception): TRACE: File "/usr/lib/pymodules/python2.7/MySQLdb/cursors.py", line 174, in execute
(nova.exception): TRACE: self.errorhandler(self, exc, value)
(nova.exception): TRACE: File "/usr/lib/pymodules/python2.7/MySQLdb/connections.py", line 36, in defaulterrorhandler
(nova.exception): TRACE: raise errorclass, errorvalue
(nova.exception): TRACE: IntegrityError: (IntegrityError) (1062, "Duplicate entry 'test' for key 'instance_types_name_key'") 'INSERT INTO instance_types (created_at, updated_at, deleted_at, deleted, name, memory_mb, vcpus, root_gb, ephemeral_gb, flavorid, swap, rxtx_factor, vcpu_weight) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)' (datetime.datetime(2012, 2, 15, 16, 26, 16, 931158), None, None, 0, u'test', 100, 100, 100, 100, 101, 0, 1, None)
(nova.exception): TRACE:
2012-02-15 17:26:16,936 ERROR nova.compute.instance_types [req-7a175400-9aa5-4272-ac17-8fa66ebaf1f3 4599637aa20740d2a59a2621948bcdea 0f0bbc8563a44a6a880c0c1ad85d5e79] DB error: (IntegrityError) (1062, "Duplicate entry 'test' for key 'instance_types_name_key'") 'INSERT INTO instance_types (created_at, updated_at, deleted_at, deleted, name, memory_mb, vcpus, root_gb, ephemeral_gb, flavorid, swap, rxtx_factor, vcpu_weight) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)' (datetime.datetime(2012, 2, 15, 16, 26, 16, 931158), None, None, 0, u'test', 100, 100, 100, 100, 101, 0, 1, None)

2012-02-15 17:26:16,937 ERROR nova.api.openstack [req-7a175400-9aa5-4272-ac17-8fa66ebaf1f3 4599637aa20740d2a59a2621948bcdea 0f0bbc8563a44a6a880c0c1ad85d5e79] Caught error: Unable to create instance type
(nova.api.openstack): TRACE: Traceback (most recent call last):
(nova.api.openstack): TRACE: File "/opt/stack/nova/nova/api/openstack/__init__.py", line 41, in __call__
(nova.api.openstack): TRACE: return req.get_response(self.application)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/request.py", line 1053, in get_response
(nova.api.openstack): TRACE: application, catch_exc_info=False)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/request.py", line 1022, in call_application
(nova.api.openstack): TRACE: app_iter = application(self.environ, start_response)
(nova.api.openstack): TRACE: File "/opt/stack/keystone/keystone/middleware/auth_token.py", line 345, in __call__
(nova.api.openstack): TRACE: return self._forward_request(env, start_response, proxy_headers)
(nova.api.openstack): TRACE: File "/opt/stack/keystone/keystone/middleware/auth_token.py", line 608, in _forward_request
(nova.api.openstack): TRACE: return self.app(env, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.7/routes/middleware.py", line 131, in __call__
(nova.api.openstack): TRACE: response = self.app(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 147, in __call__
(nova.api.openstack): TRACE: resp = self.call_func(req, *args, **self.kwargs)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 208, in call_func
(nova.api.openstack): TRACE: return self.func(req, *args, **kwargs)
(nova.api.openstack): TRACE: File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 786, in __call__
(nova.api.openstack): TRACE: content_type, body, accept)
(nova.api.openstack): TRACE: File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 834, in _process_stack
(nova.api.openstack): TRACE: action_result = self.dispatch(meth, request, action_args)
(nova.api.openstack): TRACE: File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 910, in dispatch
(nova.api.openstack): TRACE: return method(req=request, **action_args)
(nova.api.openstack): TRACE: File "/opt/stack/nova/nova/api/openstack/compute/contrib/flavormanage.py", line 71, in _create
(nova.api.openstack): TRACE: swap, rxtx_factor)
(nova.api.openstack): TRACE: File "/opt/stack/nova/nova/compute/instance_types.py", line 75, in create
(nova.api.openstack): TRACE: raise exception.InstanceTypeCreateFailed()
(nova.api.openstack): TRACE: InstanceTypeCreateFailed: Unable to create instance type
(nova.api.openstack): TRACE:

Revision history for this message
Vish Ishaya (vishvananda) wrote :

Can you verify your db type and the version of nova that you are using?

This migration is supposed to remove that key:

nova/db/sqlalchemy/migrate_repo/versions/076_remove_unique_constraints.py

in my testing that constraint was called 'name' but it looks like for you it is called 'instance_types_name_key'

we might need to update migration 76 further.

Revision history for this message
Brian Waldon (bcwaldon) wrote :

Verified on latest nova trunk (db ver 77):

root@ravenas:~/devstack# nova flavor-create m2.4 24 128 5 1
+----+------+-----------+------+----------+-------+-------------+
| ID | Name | Memory_MB | Swap | Local_GB | VCPUs | RXTX_Factor |
+----+------+-----------+------+----------+-------+-------------+
| 24 | m2.4 | 128 | | 5 | 1 | 1 |
+----+------+-----------+------+----------+-------+-------------+
root@ravenas:~/devstack# nova flavor-delete 24
root@ravenas:~/devstack# nova flavor-create m2.4 24 128 5 1
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)
root@ravenas:~/devstack# nova flavor-create m2.4 25 128 5 1
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)
root@ravenas:~/devstack# nova flavor-create m2.5 24 128 5 1
+----+------+-----------+------+----------+-------+-------------+
| ID | Name | Memory_MB | Swap | Local_GB | VCPUs | RXTX_Factor |
+----+------+-----------+------+----------+-------+-------------+
| 24 | m2.5 | 128 | | 5 | 1 | 1 |
+----+------+-----------+------+----------+-------+-------------+

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

I tested this on a fresh devstack environment. db version is 77 there.

Brian Waldon (bcwaldon)
Changed in nova:
assignee: nobody → Brian Waldon (bcwaldon)
status: New → In Progress
importance: Undecided → High
Revision history for this message
Brian Waldon (bcwaldon) wrote :

So it looks like the constraint in my table is 'instance_types_name_key', but migration 76 tried to delete a constraint identified by 'name'. Vish, how did you figure out how to get a handle on the constraints when you originally wrote the migration?

Revision history for this message
Vish Ishaya (vishvananda) wrote : Re: [Bug 932867] Re: creation of flavors with name of a deleted flavor is not possible
Download full text (11.0 KiB)

I just listed the names of the constraints in mysql by showing the table. I
many have misread it.
On Feb 15, 2012 3:10 PM, "Brian Waldon" <email address hidden> wrote:

> So it looks like the constraint in my table is
> 'instance_types_name_key', but migration 76 tried to delete a constraint
> identified by 'name'. Vish, how did you figure out how to get a handle
> on the constraints when you originally wrote the migration?
>
> --
> You received this bug notification because you are subscribed to
> OpenStack Compute (nova).
> https://bugs.launchpad.net/bugs/932867
>
> Title:
> creation of flavors with name of a deleted flavor is not possible
>
> Status in OpenStack Compute (Nova):
> In Progress
>
> Bug description:
> it possible to reuse the id of a deleted flavor but it's not possible
> to create a flavor with the name of a deleted one.
>
> stack@devstack001:~/devstack$ nova --username admin --password testing
> flavor-create test 100 100 100 100
>
> stack@devstack001:~/devstack$ nova --username admin --password testing
> flavor-list
> +-----+-----------+-----------+------+----------+-------+-------------+
> | ID | Name | Memory_MB | Swap | Local_GB | VCPUs | RXTX_Factor |
> +-----+-----------+-----------+------+----------+-------+-------------+
> | 100 | test | 100 | | 100 | 100 | 1.0 |
> | 2 | m1.small | 2048 | | 10 | 1 | 1.0 |
> | 3 | m1.medium | 4096 | | 10 | 2 | 1.0 |
> | 4 | m1.large | 8192 | | 10 | 4 | 1.0 |
> | 5 | m1.xlarge | 16384 | | 10 | 8 | 1.0 |
> +-----+-----------+-----------+------+----------+-------+-------------+
>
> stack@devstack001:~/devstack$ nova --username admin --password testing
> flavor-delete 100
>
> stack@devstack001:~/devstack$ nova --username admin --password testing
> flavor-create test 100 100 100 100
> ERROR: The server has either erred or is incapable of performing the
> requested operation. (HTTP 500)
>
> stack@devstack001:~/devstack$ nova --username admin --password testing
> flavor-create testtest 100 100 100 100
> +-----+----------+-----------+------+----------+-------+-------------+
> | ID | Name | Memory_MB | Swap | Local_GB | VCPUs | RXTX_Factor |
> +-----+----------+-----------+------+----------+-------+-------------+
> | 100 | testtest | 100 | | 100 | 100 | 1 |
> +-----+----------+-----------+------+----------+-------+-------------+
>
> stack@devstack001:~/devstack$ nova --username admin --password testing
> flavor-delete 100
>
> stack@devstack001:~/devstack$ nova --username admin --password testing
> flavor-create test 100 100 100 100
> ERROR: The server has either erred or is incapable of performing the
> requested operation. (HTTP 500)
> stack@devstack001:~/devstack$ nova --username admin --password testing
> flavor-create testtest 100 100 100 100
> ERROR: The server has either erred or is incapable of performing the
> requested operation. (HTTP 500)
>
> stack@devstack001:~/devstack$ nova --username admin --password testing
> flavor-create testtest 101 100 100 100
> E...

Brian Waldon (bcwaldon)
Changed in nova:
milestone: none → essex-4
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

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

Reviewed: https://review.openstack.org/4264
Committed: http://github.com/openstack/nova/commit/e35cc0baed1024cdf7663e144a28e06c1f4e5d2e
Submitter: Jenkins
Branch: master

commit e35cc0baed1024cdf7663e144a28e06c1f4e5d2e
Author: Brian Waldon <email address hidden>
Date: Thu Feb 16 16:26:49 2012 -0800

    Remove all uniqueness constraints in migration 76

    Fixes bug 932867

    Change-Id: I5b72af7c36cc07ee4f3e23566ed4e91c0c53b10b

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: essex-4 → 2012.1
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.