This is not a common case, but I verified that we can have a kind of partial deletion of instances.
What I saw is that instances have vm_state = DELETED but are not marked (in the DB) as deleted.
Looking at the code it's clear that the combination of vm_sate=DELETED and deleted=0 is a valid combination even if it should be a short lived one.
I think that if we find instances in that state during the _init_instance method we have to complete the deletion calling the self.conductor_api.instance_destroy(context, instance).
At this moment in the _init_instance method we are ignoring instances in that state:
def _init_instance(self, context, instance):
'''Initialize this instance during service init.'''
closing_vm_states = (vm_states.DELETED,
vm_states.SOFT_DELETED)
# instance was supposed to shut down - don't attempt
# recovery in any case
if instance['vm_state'] in closing_vm_states:
return
I think we need to perform the following actions to get to the point where we can consider the deletion completed: mapping_ destroy about_instance_ usage
- call the instance_destroy
- create the quota reservations for instnces, ram and cores quota usages
- commit the quota changes (quota_commit passing the reservations created at the previous step)
- call the block_device_
- call the notify_
- if vnc or spice are enabled, procced to the deletion of tokens