Steps to reproduce on essex-4:
1. Boot an instance using flavor ID 1
2. After the instance is active, delete the flavor (nova-manage flavor delete m1.tiny)
3. Make a call to /servers/details (ie nova list)
# nova list
The server could not comply with the request since it is either malformed or otherwise incorrect. (HTTP 400)
from nova-api.log:
2012-03-22 14:56:40 INFO nova.api.openstack.wsgi [req-43268d0b-0b3f-451f-b36f-bfcb49b68ff9 ryan test] GET http://10.10.10.90:8774/v1.1/test/servers/detail
2012-03-22 14:56:40 DEBUG nova.api.openstack.wsgi [req-43268d0b-0b3f-451f-b36f-bfcb49b68ff9 ryan test] Unrecognized Content-Type provided in request from (pid=23300
) get_body /usr/lib/python2.6/site-packages/nova/api/openstack/wsgi.py:694
2012-03-22 14:56:40 DEBUG nova.compute.api [req-43268d0b-0b3f-451f-b36f-bfcb49b68ff9 ryan test] Searching by: {'deleted': False, 'project_id': 'test'} from (pid=233
00) get_all /usr/lib/python2.6/site-packages/nova/compute/api.py:1009
2012-03-22 14:56:40 DEBUG nova.api.openstack.common [req-43268d0b-0b3f-451f-b36f-bfcb49b68ff9 ryan test] Generated ACTIVE from vm_state=active task_state=None. from
(pid=23300) status_from_state /usr/lib/python2.6/site-packages/nova/api/openstack/common.py:98
2012-03-22 14:56:40 ERROR nova.api.openstack.wsgi [req-43268d0b-0b3f-451f-b36f-bfcb49b68ff9 ryan test] Exception handling resource: 'NoneType' object is unsubscript
able
(nova.api.openstack.wsgi): TRACE: Traceback (most recent call last):
(nova.api.openstack.wsgi): TRACE: File "/usr/lib/python2.6/site-packages/nova/api/openstack/wsgi.py", line 848, in _process_stack
(nova.api.openstack.wsgi): TRACE: action_result = self.dispatch(meth, request, action_args)
(nova.api.openstack.wsgi): TRACE: File "/usr/lib/python2.6/site-packages/nova/api/openstack/wsgi.py", line 924, in dispatch
(nova.api.openstack.wsgi): TRACE: return method(req=request, **action_args)
(nova.api.openstack.wsgi): TRACE: File "/usr/lib/python2.6/site-packages/nova/api/openstack/compute/servers.py", line 382, in detail
(nova.api.openstack.wsgi): TRACE: servers = self._get_servers(req, is_detail=True)
(nova.api.openstack.wsgi): TRACE: File "/usr/lib/python2.6/site-packages/nova/api/openstack/compute/servers.py", line 465, in _get_servers
(nova.api.openstack.wsgi): TRACE: return self._view_builder.detail(req, limited_list)
(nova.api.openstack.wsgi): TRACE: File "/usr/lib/python2.6/site-packages/nova/api/openstack/compute/views/servers.py", line 123, in detail
(nova.api.openstack.wsgi): TRACE: return self._list_view(self.show, request, instances)
(nova.api.openstack.wsgi): TRACE: File "/usr/lib/python2.6/site-packages/nova/api/openstack/compute/views/servers.py", line 127, in _list_view
(nova.api.openstack.wsgi): TRACE: server_list = [func(request, server)["server"] for server in servers]
(nova.api.openstack.wsgi): TRACE: File "/usr/lib/python2.6/site-packages/nova/api/openstack/compute/views/servers.py", line 61, in wrapped
(nova.api.openstack.wsgi): TRACE: return func(self, request, instance)
(nova.api.openstack.wsgi): TRACE: File "/usr/lib/python2.6/site-packages/nova/api/openstack/compute/views/servers.py", line 97, in show
(nova.api.openstack.wsgi): TRACE: "flavor": self._get_flavor(request, instance),
(nova.api.openstack.wsgi): TRACE: File "/usr/lib/python2.6/site-packages/nova/api/openstack/compute/views/servers.py", line 172, in _get_flavor
(nova.api.openstack.wsgi): TRACE: flavor_id = instance["instance_type"]["flavorid"]
(nova.api.openstack.wsgi): TRACE: TypeError: 'NoneType' object is unsubscriptable
(nova.api.openstack.wsgi): TRACE:
2012-03-22 14:56:40 INFO nova.api.openstack.wsgi [req-43268d0b-0b3f-451f-b36f-bfcb49b68ff9 ryan test] http://10.10.10.90:8774/v1.1/test/servers/detail returned with
HTTP 400
Either users should be blocked from deleting a flavor until all instances booted from it terminate, or this should be more robust (I'd propose the latter).
The possible solutions that can be proposed for resolving this bug are:
1. Either the user has to be given a notification that the instance type or flavor cannot be deleted since the instances are associated with it, and he will be able to delete the flavor only if the instances that are associated with that respective flavor are deleted.
2. Or while fetching the instances from the instances table using "nova list", the code has to be changed in such a way the instance_type_id is not fetched and there is no association of the instances with the instance_type_id. Hence, even if the instance_type is deleted the instance list can be fetched using the "nova list" command.