Actually I'm not sure how you're hitting this, unless a concurrent thread is modifying the host_state_map dict at the same time.
When we're looping, we add the state_key (host,node) entry to host_state_map if it's not in there:
https://github.com/openstack/nova/blob/3ebc358002d3f62a9ff0a3b0f50fea4f2a5c2c91/nova/scheduler/host_manager.py#L698
and then we add that key to seen_nodes:
https://github.com/openstack/nova/blob/3ebc358002d3f62a9ff0a3b0f50fea4f2a5c2c91/nova/scheduler/host_manager.py#L708
so everything in seen_nodes should also be in host_state_map when we return the tuple of HostState objects:
https://github.com/openstack/nova/blob/3ebc358002d3f62a9ff0a3b0f50fea4f2a5c2c91/nova/scheduler/host_manager.py#L718
Actually I'm not sure how you're hitting this, unless a concurrent thread is modifying the host_state_map dict at the same time.
When we're looping, we add the state_key (host,node) entry to host_state_map if it's not in there:
https:/ /github. com/openstack/ nova/blob/ 3ebc358002d3f62 a9ff0a3b0f50fea 4f2a5c2c91/ nova/scheduler/ host_manager. py#L698
and then we add that key to seen_nodes:
https:/ /github. com/openstack/ nova/blob/ 3ebc358002d3f62 a9ff0a3b0f50fea 4f2a5c2c91/ nova/scheduler/ host_manager. py#L708
so everything in seen_nodes should also be in host_state_map when we return the tuple of HostState objects:
https:/ /github. com/openstack/ nova/blob/ 3ebc358002d3f62 a9ff0a3b0f50fea 4f2a5c2c91/ nova/scheduler/ host_manager. py#L718