dashboard显示有足够资源创建虚拟机
创建一个1c2g20g配置的虚拟机,在过滤时把10-197-0-2这个主机过滤掉了,日志如下:
2024-03-25 17:52:14.087 26 DEBUG nova.scheduler.filters.disk_filter [req-8f2f32fb-1efe-4e5d-81fc-618210c7c76d 773d668892074e86a2ef8ba10b833d84 774e02ab524441ba9dcdfc679ea42b4c - default default] (10-197-0-2, 10-197-0-2) ram: 84620MB disk: 2048MB io_ops: 0 instances: 13 does not have 20480 MB usable disk, it only has 2048.0 MB usable disk. host_passes /var/lib/kolla/venv/lib/python2.7/site-packages/nova/scheduler/filters/disk_filter.py:94
说明:该主机10-197-0-2只有2048.0MB的磁盘空间,不能调度到该主机上
继续看日志:
Update host state from compute node: ComputeNode(cpu_allocation_ratio=16.0,cpu_info='{"vendor": "Intel", "model": "Skylake-Server-IBRS", "arch": "x86_64", "features": ["pku", "rtm", "tsc_adjust", "vme", "pge", "xsaveopt", "smep", "fpu", "lm", "tsc", "adx", "fxsr", "tm", "pclmuldq", "xgetbv1", "tsc-deadline", "arat", "de", "aes", "pse", "sse", "f16c", "ds", "mpx", "avx512f", "avx2", "pbe", "cx16", "ds_cpl", "movbe", "intel-pt", "ospke", "vmx", "sep", "avx512dq", "stibp", "xsave", "erms", "hle", "est", "smx", "abm", "sse4.1", "sse4.2", "ssbd", "acpi", "mmx", "osxsave", "clwb", "dca", "popcnt", "invtsc", "tm2", "pcid", "pdcm", "avx512vl", "x2apic", "smap", "clflush", "dtes64", "xtpr", "avx512bw", "msr", "fma", "cx8", "mce", "avx512cd", "mca", "lahf_lm", "rdseed", "apic", "fsgsbase", "rdtscp", "ssse3", "pse36", "mtrr", "avx", "syscall", "invpcid", "cmov", "spec-ctrl", "clflushopt", "pat", "3dnowprefetch", "nx", "pae", "md-clear", "ht", "pdpe1gb", "rdrand", "xsavec", "pni", "sse2", "ss", "bmi1", "bmi2", "xsaves"], "topology": {"cores": 10, "cells": 1, "threads": 2, "sockets": 2}}',created_at=2023-03-10T02:26:28Z,current_workload=0,deleted=False,deleted_at=None,disk_allocation_ratio=1.0,disk_available_least=2,free_disk_gb=84,free_ram_mb=84620,host='10-197-0-2',host_ip=10.197.0.2,hypervisor_hostname='10-197-0-2',hypervisor_type='QEMU',hypervisor_version=2012000,id=12,local_gb=549,local_gb_used=465,mapped=1,memory_mb=128240,memory_mb_used=43620,metrics='[]',numa_topology='{"nova_object.version": "1.2", "nova_object.changes": ["cells"], "nova_object.name": "NUMATopology", "nova_object.data": {"cells": [{"nova_object.version": "1.4", "nova_object.changes": ["network_metadata", "cpu_usage", "memory_usage", "cpuset", "mempages", "pinned_cpus", "siblings", "memory", "pcpuset", "id"], "nova_object.name": "NUMACell", "nova_object.data": {"memory": 128240, "network_metadata": {"nova_object.version": "1.0", "nova_object.changes": ["physnets", "tunneled"], "nova_object.name": "NetworkMetadata", "nova_object.data": {"physnets": [], "tunneled": false}, "nova_object.namespace": "nova"}, "cpu_usage": 0, "memory_usage": 0, "cpuset": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], "pinned_cpus": [], "siblings": [[1, 21], [10, 30], [11, 31], [34, 14], [0, 20], [25, 5], [8, 28], [9, 29], [32, 12], [24, 4], [35, 15], [27, 7], [18, 38], [2, 22], [19, 39], [17, 37], [3, 23], [33, 13], [26, 6], [16, 36]], "mempages": [{"nova_object.version": "1.1", "nova_object.changes": ["total", "used", "reserved", "size_kb"], "nova_object.name": "NUMAPagesTopology", "nova_object.data": {"used": 0, "total": 32829531, "reserved": 0, "size_kb": 4}, "nova_object.namespace": "nova"}, {"nova_object.version": "1.1", "nova_object.changes": ["total", "used", "reserved", "size_kb"], "nova_object.name": "NUMAPagesTopology", "nova_object.data": {"used": 0, "total": 0, "reserved": 0, "size_kb": 2048}, "nova_object.namespace": "nova"}, {"nova_object.version": "1.1", "nova_object.changes": ["total", "used", "reserved", "size_kb"], "nova_object.name": "NUMAPagesTopology", "nova_object.data": {"used": 0, "total": 0, "reserved": 0, "size_kb": 1048576}, "nova_object.namespace": "nova"}], "pcpuset": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], "id": 0}, "nova_object.namespace": "nova"}]}, "nova_object.namespace": "nova"}',pci_device_pools=PciDevicePoolList,ram_allocation_ratio=1.5,running_vms=13,service_id=None,stats={failed_builds='0',io_workload='0',num_instances='13',num_os_type_None='13',num_proj_514e22c33ba94e1e81454ec813999aa6='9',num_proj_774e02ab524441ba9dcdfc679ea42b4c='4',num_task_None='13',num_vm_active='13'},supported_hv_specs=[HVSpec,HVSpec,HVSpec,HVSpec],updated_at=2024-03-25T09:39:23Z,uuid=c6c68e56-7e23-4e79-974c-886de389819a,vcpus=40,vcpus_used=23) _locked_update /var/lib/kolla/venv/lib/python2.7/site-packages/nova/scheduler/host_manager.py:172
可以看到"disk_available_least=2,free_disk_gb=84"是以disk_available_least作为filter判断标准。
看源码看这个值disk_available_least如何获取:
disk_over_committed = self._get_disk_over_committed_size_total()available_least = disk_free_gb * units.Gi - disk_over_committeddata['disk_available_least'] = available_least / units.Gi
elif disk_type == 'file' and driver_type == 'qcow2':qemu_img_info = disk_api.get_disk_info(path)dk_size = qemu_img_info.disk_sizevirt_size = qemu_img_info.virtual_sizebacking_file = libvirt_utils.get_disk_backing_file(path)over_commit_size = int(virt_size) - dk_size
disk_available_least =主机实际的空闲磁盘空间 - 所有虚拟机可增量的磁盘空间
分析:'所有虚拟机可增量的磁盘空间'这个值是准确的,和dashboard分配的disk一致,disk_available_least过小,主要是'主机实际的空闲磁盘空间'过下。
再看主机实际的磁盘使用量:
root@10-197-0-2:~# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 63G 0 63G 0% /dev
tmpfs tmpfs 63G 0 63G 0% /dev/shm
tmpfs tmpfs 63G 999M 62G 2% /run
tmpfs tmpfs 63G 0 63G 0% /sys/fs/cgroup
/dev/sda2 xfs 550G 100G 450G 19% /