No valid host was found. There are not enough hosts available-----openstack建虚拟机直接报错
一、问题现象:
本次环境中只有一个计算节点,创建虚拟机直接报错,使用nova show 看到报错如下图:
"message": "No valid host was found. There are not enough hosts available.", "code": 500
二、解决思路:
1、查看计算节点的nova-compute 日志,发现如下日志:
2019-11-21 19:47:09.484 8 ERROR nova.scheduler.client.report [req-cbc37e88-16be-4b5b-be98-d889cd1b01dc - - - - -] [req-a5a6d438-3f63-49aa-9dd2-98d061b122b4] Failed to create resource provider record in placement API for UUID d878a164-6499-43d4-9772-b77107a1bb8c. Got 409: {"errors": [
{"status": 409, "request_id": "req-a5a6d438-3f63-49aa-9dd2-98d061b122b4", "detail": "There was a conflict when trying to complete your request.
Conflicting resource provider name: compute1 already exists. ", "title": "Conflict"}
2019-11-21 19:47:09.485 8 ERROR nova.compute.manager [req-cbc37e88-16be-4b5b-be98-d889cd1b01dc - - - - -] Error updating resources for node compute1.: ResourceProviderCreationFailed: Failed to create resource provider compute1
发现ResourceProviderCreationFailed: Failed to create resource provider compute1 ,发现resource Provider 创建失败。怀疑数据库resource provider 表没有建出来,继续查看nova-nova-scheduler.log。
2、查看nova-scheduler.log
2019-11-21 20:18:43.360 29 INFO nova.filters [req-448bd5fa-ddc8-45d9-9b8b-a63bdb691335 e0111848d3904a7288df61cac5163f4f 9be97009f556459cb1814232dbedb4a3 - default default] Filter RetryFilter returned 0 hosts
2019-11-21 20:18:43.362 29 INFO nova.filters [req-448bd5fa-ddc8-45d9-9b8b-a63bdb691335 e0111848d3904a7288df61cac5163f4f 9be97009f556459cb1814232dbedb4a3 - default default] Filtering removed all hosts for the request with instance ID 'c9542c1c-191e-49f2-815a-fdcacc081af6'. Filter results: ['RetryFilter: (start: 0, end: 0)']
3、进数据查看数据库表
mysql> use nova_api;
mysql[nova_api] > select * from resource_providers;
+---------------------+---------------------+----+--------------------------------------+----------+------------+----------+------------------+--------------------+
| created_at | updated_at | id | uuid | name | generation | can_host | root_provider_id | parent_provider_id |
+---------------------+---------------------+----+--------------------------------------+----------+------------+----------+------------------+--------------------+
| 2019-11-21 06:17:39 | 2019-11-21 06:17:41 | 3 | 16d1bd53-7919-4fef-9a11-a0e98c149823 | compute1 | 1 | NULL | 3 | NULL |
+---------------------+---------------------+----+--------------------------------------+----------+------------+----------+------------------+--------------------+
1 row in set (0.00 sec)
发现有数据。重新创建虚拟机,依然会发生报错,
4、尝试将compute节点从nova service-list中删除,并重新加入到集群中
# 停掉compute节点的nova-compute 服务
nova service-delete <计算节点的uuid>
# 开启计算节点的nova-compute服务,让计算节点重新注册
尝试创建虚拟机,发现还是报错。返回去,查看nova-compute的日志发现 There was a conflict when trying to complete your request.
Conflicting resource provider name: compute1 already exists.
。提示矛盾。
5、再次进入数据库,执行 select * from resource_providers;
mysql> use nova_api;
mysql[nova_api] > select * from resource_providers;
+---------------------+---------------------+----+--------------------------------------+----------+------------+----------+------------------+--------------------+
| created_at | updated_at | id | uuid | name | generation | can_host | root_provider_id | parent_provider_id |
+---------------------+---------------------+----+--------------------------------------+----------+------------+----------+------------------+--------------------+
| 2019-11-21 06:17:39 | 2019-11-21 06:17:41 | 3 | 16d1bd53-7919-4fef-9a11-a0e98c149823 | compute1 | 1 | NULL | 3 | NULL |
+---------------------+---------------------+----+--------------------------------------+----------+------------+----------+------------------+--------------------+
1 row in set (0.00 sec)
发现新注册的计算节点,但是resource_providers的uuid 没有发生变化,怀疑是注册compute节点的时候,并没有更新resource_providers,尝试删除resource_providers;
6、查找官网,找到了操作 resource_providers
的openstack命令,执行如下操作。
相关文档:https://docs.openstack.org/osc-placement/latest/cli/index.html
# 安装osc-placement 软件包,生成命令行工具
# 执行如下命令:
export OS_PLACEMENT_API_VERSION=1.10
openstack allocation candidate list --resource VCPU=1
# 查看当前resource provider
[root@control1 ~]# openstack resource provider list
+--------------------------------------+----------+------------+
| uuid | name | generation |
+--------------------------------------+----------+------------+
| 16d1bd53-7919-4fef-9a11-a0e98c149823 | compute1 | 2 |
+--------------------------------------+----------+------------+
# 停止计算节点nova-compute服务
# 从service 中删除compute1
nova service-delete <uuid>
# 删除当前resource provider
openstack resource provider delete 16d1bd53-7919-4fef-9a11-a0e98c149823
# 重启nova-compute服务,让其自动注册
# 查看当前resource provider
[root@control1 ~]# openstack resource provider list
+--------------------------------------+----------+------------+
| uuid | name | generation |
+--------------------------------------+----------+------------+
| b32cd7b5-26c6-4998-97f1-79fa2315871b | compute1 | 2 |
+--------------------------------------+----------+------------+
# # 执行如下命令,验证是否更新了数据
export OS_PLACEMENT_API_VERSION=1.10
openstack allocation candidate list --resource VCPU=1
执行创建云主机,云主机成功创建。