There is handling later in the looping where the instance from the DB isn't on the hypervisor, and in that case we assume no power state:
https://github.com/openstack/nova/blob/4ad414f3b1216393301ef268a64e61ca1a3d5be9/nova/compute/manager.py#L6223-L6227
Which actually makes this probably wrong:
https://github.com/openstack/nova/blob/4ad414f3b1216393301ef268a64e61ca1a3d5be9/nova/compute/manager.py#L6282-L6294
So let's consider this scenario: we have 5 instances on the hypervisor and 5 in the database, that's all normal. However, we're currently taking snapshots of two of those instances. If we filter on task_state != None, then we'd get the warning in:
https://github.com/openstack/nova/blob/4ad414f3b1216393301ef268a64e61ca1a3d5be9/nova/compute/manager.py#L6180
Even though the instances are on the hypervisor.
I think the thing we need to warn about is if there are more instances for that host in the DB than what's in the hypervisor, so change:
if num_vm_instances != num_db_instances:
to
if num_vm_instances < num_db_instances:
There is handling later in the looping where the instance from the DB isn't on the hypervisor, and in that case we assume no power state:
https:/ /github. com/openstack/ nova/blob/ 4ad414f3b121639 3301ef268a64e61 ca1a3d5be9/ nova/compute/ manager. py#L6223- L6227
Which actually makes this probably wrong:
https:/ /github. com/openstack/ nova/blob/ 4ad414f3b121639 3301ef268a64e61 ca1a3d5be9/ nova/compute/ manager. py#L6282- L6294
So let's consider this scenario: we have 5 instances on the hypervisor and 5 in the database, that's all normal. However, we're currently taking snapshots of two of those instances. If we filter on task_state != None, then we'd get the warning in:
https:/ /github. com/openstack/ nova/blob/ 4ad414f3b121639 3301ef268a64e61 ca1a3d5be9/ nova/compute/ manager. py#L6180
Even though the instances are on the hypervisor.
I think the thing we need to warn about is if there are more instances for that host in the DB than what's in the hypervisor, so change:
if num_vm_instances != num_db_instances:
to
if num_vm_instances < num_db_instances: