To find the gap when placement api db out of sync or keep receiving NoValidHost error. There is great chance resources in placement db is out of track. One change in nova scheduler is a memory.disk.cpu filters are there any more, instead nova scheduler ask placement api for a list HV candidates by flavor first, then nova scheduler continues the filtering like compute_filter etc…
DB query to get basic capacity details:
select p.uuid, p.name hypervisor_hostname,
(select i.total from inventories i where p.id=i.resource_provider_id and i.resource_class_id=0) vcpus,
(select sum(used) from allocations a where a.resource_provider_id=p.id and a.resource_class_id=0) vcpus_used,
(select i.total from inventories i where p.id=i.resource_provider_id and i.resource_class_id=1) memory_mb,
(select sum(used) from allocations a where a.resource_provider_id=p.id and a.resource_class_id=1) memory_mb_used,
(select i.total from inventories i where p.id=i.resource_provider_id and i.resource_class_id=2) local_gb,
(select sum(used) from allocations a where a.resource_provider_id=p.id and a.resource_class_id=2) local_gb_used,
(select count(id) from allocations a where a.resource_provider_id=p.id and a.resource_class_id=2) running_vms
from resource_providers p order by p.name;
combine nova db + placement
assume running this query in placement api db and nova cellx db name is nova_cell_1
select x.hypervisor_hostname, x.vcpus p_vcpus, y.vcpus n_vcpus, x.vcpus_used p_vcpus_used,y.vcpus_used n_vcpus_used, x.memory_mb p_memory_mb, y.memory_mb n_memory_mb, x.memory_mb_used p_memory_mb_used, y.memory_mb_used n_memory_mb_used, x.local_gb p_local_gb, y.local_gb n_local_gb, x.local_gb_used p_local_gb_used, y.local_gb_used n_local_gb_used, x.running_vms p_running_vms, y.running_vms n_running_vms from
(select p.name hypervisor_hostname,
(select i.total from inventories i where p.id=i.resource_provider_id and i.resource_class_id=0) vcpus,
(select sum(used) from allocations a where a.resource_provider_id=p.id and a.resource_class_id=0) vcpus_used,
(select i.total from inventories i where p.id=i.resource_provider_id and i.resource_class_id=1) memory_mb,
(select sum(used) from allocations a where a.resource_provider_id=p.id and a.resource_class_id=1) memory_mb_used,
(select i.total from inventories i where p.id=i.resource_provider_id and i.resource_class_id=2) local_gb,
(select sum(used) from allocations a where a.resource_provider_id=p.id and a.resource_class_id=2) local_gb_used,
(select count(id) from allocations a where a.resource_provider_id=p.id and a.resource_class_id=2) running_vms
from resource_providers p) x
join
(select hypervisor_hostname, vcpus, vcpus_used, memory_mb, memory_mb_used, local_gb, local_gb_used, running_vms from nova_cell_1.compute_nodes where deleted=0 ) y
on x.hypervisor_hostname=y.hypervisor_hostname
order by x.hypervisor_hostname;
Any utility to rebuild db?