nova/scheduler/host_manager.py uses a simple model for determination if a host has enough resources to run a new instance. It simply adds all resources for all instances that are scheduled for that host. However, these instances can be broken (in ERROR state) - they can simply do not exist at all, so, they don's consume resources. An instance can be broken if there are no free networks, if its images are improper, or even due to RPC timeout in nova-compute as it happens. These instances cannot be revived and should not be taken into account.
I have a question, if the instance becomes to ERROR state during spawn in hypervisor, in other words, the disk/image has already been created(disk resource need to be consumed?), how we deal this situation?