OpenStack Compute (Nova)

Confusion between UUID instance ID and integer ID in instance_info_cache_delete_by_instance_id

Reported by justinsb on 2011-12-13
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
High
Alex Meade

Bug Description

I can't delete an instance when using postgresql, because the code is passing an integer instance id where a UUID is expected to instance_info_cache_delete_by_instance_id. I expect the bug also exists on MySQL, but MySQL is much more liberal with parameter conversion, though the data won't be deleted.

2011-12-12 01:56:01,892 DEBUG nova.api [092ca398-491c-c49c-e6b0-d9de0123a2c3 e51d453d-e88d-ed8d-886f-f7f91f111a2d e51d453d-e88d-ed8d-886f-f7f91f111a2d] arg: InstanceId.1 val: i-00000001 from (pid=7157) __call__ /usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/api/ec2/__init__.py:253
2011-12-12 01:56:01,892 DEBUG nova.api.ec2.cloud [092ca398-491c-c49c-e6b0-d9de0123a2c3 e51d453d-e88d-ed8d-886f-f7f91f111a2d e51d453d-e88d-ed8d-886f-f7f91f111a2d] Going to start terminating instances from (pid=7157) terminate_instances /usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/api/ec2/cloud.py:1296
2011-12-12 01:56:01,957 DEBUG nova.compute.api [092ca398-491c-c49c-e6b0-d9de0123a2c3 e51d453d-e88d-ed8d-886f-f7f91f111a2d e51d453d-e88d-ed8d-886f-f7f91f111a2d] Going to try to terminate a7da7be8-0369-cf4a-bfee-f7a74a2b029d from (pid=7157) delete /usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/compute/api.py:812
2011-12-12 01:56:01,964 ERROR nova.api [092ca398-491c-c49c-e6b0-d9de0123a2c3 e51d453d-e88d-ed8d-886f-f7f91f111a2d e51d453d-e88d-ed8d-886f-f7f91f111a2d] Unexpected error raised: (ProgrammingError) operator does not exist: character varying = integer
LINE 3: WHERE instance_info_caches.instance_id = 1
                                               ^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
(nova.api): TRACE: Traceback (most recent call last):
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/api/ec2/__init__.py", line 357, in __call__
(nova.api): TRACE: result = api_request.invoke(context)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/api/ec2/apirequest.py", line 90, in invoke
(nova.api): TRACE: result = method(context, **args)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/api/ec2/cloud.py", line 1300, in terminate_instances
(nova.api): TRACE: self.compute_api.delete(context, instance)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/scheduler/api.py", line 321, in wrapped_f
(nova.api): TRACE: return f(*args, **kwargs)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/compute/api.py", line 817, in delete
(nova.api): TRACE: self._delete(context, instance)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/compute/api.py", line 807, in _delete
(nova.api): TRACE: self.db.instance_destroy(context, instance['id'])
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/db/api.py", line 514, in instance_destroy
(nova.api): TRACE: return IMPL.instance_destroy(context, instance_id)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/db/sqlalchemy/api.py", line 113, in wrapper
(nova.api): TRACE: return f(*args, **kwargs)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/db/sqlalchemy/api.py", line 1136, in instance_destroy
(nova.api): TRACE: session=session)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/db/sqlalchemy/api.py", line 113, in wrapper
(nova.api): TRACE: return f(*args, **kwargs)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/db/sqlalchemy/api.py", line 1625, in instance_info_cache_delete_by_instance_id
(nova.api): TRACE: instance_info_cache_update(context, instance_id, values, session)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/db/sqlalchemy/api.py", line 113, in wrapper
(nova.api): TRACE: return f(*args, **kwargs)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/db/sqlalchemy/api.py", line 1605, in instance_info_cache_update
(nova.api): TRACE: session=session)

(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/db/sqlalchemy/api.py", line 1625, in instance_info_cache_delete_by_instance_id
(nova.api): TRACE: instance_info_cache_update(context, instance_id, values, session)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/db/sqlalchemy/api.py", line 113, in wrapper
(nova.api): TRACE: return f(*args, **kwargs)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/db/sqlalchemy/api.py", line 1605, in instance_info_cache_update
(nova.api): TRACE: session=session)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/db/sqlalchemy/api.py", line 113, in wrapper
(nova.api): TRACE: return f(*args, **kwargs)
(nova.api): TRACE: File "/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/db/sqlalchemy/api.py", line 1589, in instance_info_cache_get
(nova.api): TRACE: filter_by(instance_id=instance_id).\
(nova.api): TRACE: File "build/bdist.solaris-2.11-i86pc/egg/sqlalchemy/orm/query.py", line 1988, in first
(nova.api): TRACE: ret = list(self[0:1])
(nova.api): TRACE: File "build/bdist.solaris-2.11-i86pc/egg/sqlalchemy/orm/query.py", line 1882, in __getitem__
(nova.api): TRACE: return list(res)
(nova.api): TRACE: File "build/bdist.solaris-2.11-i86pc/egg/sqlalchemy/orm/query.py", line 2057, in __iter__
(nova.api): TRACE: return self._execute_and_instances(context)
(nova.api): TRACE: File "build/bdist.solaris-2.11-i86pc/egg/sqlalchemy/orm/query.py", line 2072, in _execute_and_instances
(nova.api): TRACE: result = conn.execute(querycontext.statement, self._params)
(nova.api): TRACE: File "build/bdist.solaris-2.11-i86pc/egg/sqlalchemy/engine/base.py", line 1405, in execute
(nova.api): TRACE: params)
(nova.api): TRACE: File "build/bdist.solaris-2.11-i86pc/egg/sqlalchemy/engine/base.py", line 1538, in _execute_clauseelement
(nova.api): TRACE: compiled_sql, distilled_params
(nova.api): TRACE: File "build/bdist.solaris-2.11-i86pc/egg/sqlalchemy/engine/base.py", line 1646, in _execute_context
(nova.api): TRACE: context)
(nova.api): TRACE: File "build/bdist.solaris-2.11-i86pc/egg/sqlalchemy/engine/base.py", line 1639, in _execute_context
(nova.api): TRACE: context)
(nova.api): TRACE: File "build/bdist.solaris-2.11-i86pc/egg/sqlalchemy/engine/default.py", line 330, in do_execute
(nova.api): TRACE: cursor.execute(statement, parameters)
(nova.api): TRACE: ProgrammingError: (ProgrammingError) operator does not exist: character varying = integer
(nova.api): TRACE: LINE 3: WHERE instance_info_caches.instance_id = 1
(nova.api): TRACE: ^
(nova.api): TRACE: HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
(nova.api): TRACE: 'SELECT instance_info_caches.created_at AS instance_info_caches_created_at, instance_info_caches.updated_at AS instance_info_caches_updated_at, instance_info_caches.deleted_at AS instance_info_caches_deleted_at, instance_info_caches.deleted AS instance_info_caches_deleted, instance_info_caches.id AS instance_info_caches_id, instance_info_caches.network_info AS instance_info_caches_network_info, instance_info_caches.instance_id AS instance_info_caches_instance_id \nFROM instance_info_caches \nWHERE instance_info_caches.instance_id = %(instance_id_1)s \n LIMIT %(param_1)s' {'param_1': 1, 'instance_id_1': 1}

Thierry Carrez (ttx) on 2011-12-21
Changed in nova:
importance: Undecided → High
status: New → Confirmed
Alex Meade (alex-meade) wrote :

This is true! It's as simple as instance_destroy passes instance id instead of instance uuid into instance_info_cache_delete in nova/db/sqlalchemy/api.py.

Alex Meade (alex-meade) on 2012-01-11
Changed in nova:
assignee: nobody → Alex Meade (alex-meade)
status: Confirmed → In Progress

Reviewed: https://review.openstack.org/2972
Committed: http://github.com/openstack/nova/commit/26b7b9457a5899ecca93fd67d3879efcad4e4968
Submitter: Jenkins
Branch: master

commit 26b7b9457a5899ecca93fd67d3879efcad4e4968
Author: Alex Meade <email address hidden>
Date: Wed Jan 11 19:43:26 2012 +0000

    Call to instance_info_cache_delete to use uuid

    Fixes bug 903497
    Also updated incorrect calls to instance_destroy that were using uuids.

    Change-Id: I25eead020ceb7ebf7234c268543ad77d8ecf1185

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx) on 2012-01-25
Changed in nova:
milestone: none → essex-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2012-04-05
Changed in nova:
milestone: essex-3 → 2012.1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers