So you'd either need to limit that and do paging (batches of 50 instances) or pass something down from the compute manager to driver.manage_image_cache to indicate that instances from more than one host are involved (shared storage) and the behavior could be different in that case.
The other optimization about only querying for swap BDMs is also something that could be done regardless of chunking.
I guess https:/ /github. com/openstack/ nova/blob/ 56811efa3583dfa 3c03f9e43a9802b be21e45bbd/ nova/virt/ imagecache. py#L53 was done specifically to avoid a message storm to conductor and the database:
https:/ /review. openstack. org/#/c/ 298023/
So you'd either need to limit that and do paging (batches of 50 instances) or pass something down from the compute manager to driver. manage_ image_cache to indicate that instances from more than one host are involved (shared storage) and the behavior could be different in that case.
The other optimization about only querying for swap BDMs is also something that could be done regardless of chunking.