最近手动搭建了一个openstack环境,创建硬盘时失败,查看日志,提示无法进行调度,怀疑是cinder节点出现问题,去cinder节点查看服务 ,状态显示正常。
systemctl status openstack-cinder-volume.service
然后在控制节点查看cinder服务,openstack volume service list
正常情况下显示:
结果显示cinder-volume的state为down,查看日志发现没有任何错误信息,重启cinder的各种服务仍然没有效果,最后决定跟踪源码(说明:文中代码对应的是OpenStack Train版)。
找到openstack volume service list对应的实现代码。
now = timeutils.utcnow(with_timezone=True)
由于openstack-cinder-api.servic服务在controller节点启动,所以获取的是controller节点的当前时间。
services = objects.ServiceList.get_all(context, filters)最终会从cinder数据库的services表中获取所有服务数据。
alive = abs(delta_sec) <= CONF.service_down_time,比较时间差的绝对值是否小于配置的service_down_time,其中service_down_time默认时间是60s。
cfg.IntOpt('service_down_time', default=60, help='Maximum time since last check-in for a service to be ' 'considered up'), |
art = "up" if alive else "down