Comment 1 for bug 1041581

Revision history for this message
Nikola Đipanov (ndipanov) wrote :

Hi,

I spent some time looking into this and the problem seems to be in the nova.compute.api.API._create_instance method.

What is happening is that this method calls another method of the same class - _check_num_instances_quota which in turn calls QUOTAS.reserve method that reserves an instance. However after this not all possible paths will resutl in the reservation being commited/rolled back, and one of these paths is indeed when the image lookup fails with Glance. (it will cause an ImageNotFound exception that is only caught several levels up by the nova.api.openstack.compute.servers.create - which of course does not rollback the reservation).

(Two things worth mentioning:
* if you try to create an instance with a non existant image using the python-novaclient or dashbord - it will be caught before it hits the nova API and thus will not cause the wrong reservations.
* Since the reservations do expire - they will be refreshed and thus freed up at one point in time in a real system. The default value is 24 hours (reservation_expire config option in nova.quota)

The quick fix is of course to make sure all reservations are rolledback/commited. inside the _create_instance method. I will propose a fix for this soon.

However this makes me think that there may be more places where quota reservations are handeled in such a non-symetric way - which makes me think that we may want to provide a more straightforward method of dealing with them.