When unshelving operation is on-going, the VM may be in SHELVE_OFFLOADED state, however, its task state may be already set to SPAWNING. The instance claim happens when VM is in SHELVE_OFFLOADED/SPAWNING state:
so when update_available_resources is triggered the if condition does not take this instance usage into consideration effectively removing resources claimed by the instance.
It seems to me that it is due to this if condition racing with unshelve operation:
https:/ /github. com/openstack/ nova/blob/ f0565e84ee9578d 6dafd22d57fb0c9 5cb3984c1e/ nova/compute/ resource_ tracker. py#L1673
When unshelving operation is on-going, the VM may be in SHELVE_OFFLOADED state, however, its task state may be already set to SPAWNING. The instance claim happens when VM is in SHELVE_ OFFLOADED/ SPAWNING state:
https:/ /github. com/openstack/ nova/blob/ f0565e84ee9578d 6dafd22d57fb0c9 5cb3984c1e/ nova/compute/ manager. py#L7075
so when update_ available_ resources is triggered the if condition does not take this instance usage into consideration effectively removing resources claimed by the instance.