nova虚拟机power_state状态NOSTATE

虚机机运行正常,但 power_state 为 NOSTATE

  1. 现象

查看虚拟机 status 是 ACTIVE 的,但是 power_state 是 NOSTATE

 openstack server show 050710bb-dbc5-44f2-aec8-7842fd0eac63 
+-------------------------------------+-----------------------------------------------------------+
| Field                               | Value                                                     |
+-------------------------------------+-----------------------------------------------------------+

                                    ......
| OS-EXT-STS:power_state              | NOSTATE                                                   |

| status                              | ACTIVE                                                    |

                                    ......

  1. 查看 compute 日志
2019-08-06 16:02:05.346 13910 WARNING nova.compute.manager [req-a5db4fe4-250d-4795-9bbc-08be341dc900 8a974b0ae27f40ee87a92916f909360d c0f1fa6073be435491e4309ce0be959b - default default] [instance: 050710bb-dbc5-44f2-aec8-7842fd0eac63] Instance is unexpectedly not found. Ignore.: InstanceNotFound: Instance 050710bb-dbc5-44f2-aec8-7842fd0eac63 could not be found.
2019-08-06 16:02:05.347 13910 DEBUG oslo_concurrency.lockutils [req-a5db4fe4-250d-4795-9bbc-08be341dc900 8a974b0ae27f40ee87a92916f909360d c0f1fa6073be435491e4309ce0be959b - default default] Lock "050710bb-dbc5-44f2-aec8-7842fd0eac63" released by "nova.compute.manager.query_driver_power_state_and_sync" :: held 0.081s inner /usr/lib/python2.7/site-packages/oslo_concurrency/lockutils.py:285

发现 InstanceNotFound: Instance 050710bb-dbc5-44f2-aec8-7842fd0eac63 could not be found 的日志

file:  /usr/lib/python2.7/site-packages/nova/compute/manager.py 

    def _query_driver_power_state_and_sync(self, context, db_instance):
        if db_instance.task_state is not None:
            LOG.info("During sync_power_state the instance has a "
                     "pending task (%(task)s). Skip.",
                     {'task': db_instance.task_state}, instance=db_instance)
            return
        # No pending tasks. Now try to figure out the real vm_power_state.
        try:
            vm_instance = self.driver.get_info(db_instance)
            vm_power_state = vm_instance.state
        except exception.InstanceNotFound:         "捕获InstanceNotFound"
            vm_power_state = power_state.NOSTATE    
        # Note(maoy): the above get_info call might take a long time,
        # for example, because of a broken libvirt driver.
        try:
            self._sync_instance_power_state(context,
                                            db_instance,
                                            vm_power_state,
                                            use_slave=True)
        except exception.InstanceNotFound:
            # NOTE(hanlind): If the instance gets deleted during sync,
            # silently ignore.
            pass

由于 manager.py 捕获到 InstanceNotFound 设置 vm_power_state=NOSTATE

  1. 原因

    由于之前 migrate ERROR 导致 instance 实际启动的节点和数据库记录的节点不一致,comoute 通过 manager.py 捕获到 InstanceNotFound, 所以把 vm_power_state 状态置为 NOSTATE

  2. 解决办法

    重新 update 数据库,和实际情况保持一致,硬重启虚拟机( 后端存储使用的是 ceph )

你可能感兴趣的:(nova虚拟机power_state状态NOSTATE)