openstack-虚拟机在线迁移失败问题及解决办法

13 篇文章 0 订阅

原博客地址:http://blog.csdn.net/lynn_kong

内容系本人学习、研究和总结,如有雷同,实属荣幸!


更新历史;

2013.07.17  该问题在最新的主干分支中不存在了,因为nova-scheduler中的代码有部分重构过,不知是无意还是有意,修复了这个bug

/、虽然修改了,通过这个学习可以了解更多


version:OpenStack Grizzly 2013.1.2

hypervisor:KVM

shared  storage: no


1、问题描述

我的环境上有一台虚拟机,信息如下:

[plain]  view plain copy
  1. root@controller:~# nova show ubuntu_bdm_with_keypair  
  2. +-------------------------------------+----------------------------------------------------------+  
  3. | Property                            | Value                                                    |  
  4. +-------------------------------------+----------------------------------------------------------+  
  5. | status                              | ACTIVE                                                   |  
  6. | updated                             | 2013-07-11T05:15:46Z                                     |  
  7. | OS-EXT-STS:task_state               | None                                                     |  
  8. | OS-EXT-SRV-ATTR:host                | controller                                               |  
  9. | key_name                            | mykey                                                    |  
  10. | image                               | Attempt to boot from volume - no image supplied          |  
  11. | hostId                              | 6c1b0e7f432cdca4fe62380f271d7b83999b3aeee6e6893cc90db44a |  
  12. | OS-EXT-STS:vm_state                 | active                                                   |  
  13. | OS-EXT-SRV-ATTR:instance_name       | instance-00000005                                        |  
  14. | OS-EXT-SRV-ATTR:hypervisor_hostname | controller.konglingxian.com                              |  
  15. | flavor                              | kong.flavor (6)                                          |  
  16. | id                                  | 6cd558d9-e924-4598-8e63-e86a20929bd9                     |  
  17. | security_groups                     | [{u'name': u'default'}]                                  |  
  18. | demo_net1 network                   | 10.1.1.2, 128.3.11.101                                   |  
  19. | user_id                             | 9bfc5979e8774ea99f54ba78d07c3bc0                         |  
  20. | name                                | ubuntu_bdm_with_keypair                                  |  
  21. | created                             | 2013-07-10T07:48:04Z                                     |  
  22. | tenant_id                           | d9a9b59b0be94489a85f51ba3ced15ce                         |  
  23. | OS-DCF:diskConfig                   | MANUAL                                                   |  
  24. | metadata                            | {}                                                       |  
  25. | accessIPv4                          |                                                          |  
  26. | accessIPv6                          |                                                          |  
  27. | progress                            | 0                                                        |  
  28. | OS-EXT-STS:power_state              | 1                                                        |  
  29. | OS-EXT-AZ:availability_zone         | nova                                                     |  
  30. | config_drive                        |                                                          |  
  31. +-------------------------------------+----------------------------------------------------------+  
环境上两个节点:

[plain]  view plain copy
  1. root@controller:~# nova hypervisor-list  
  2. +----+-----------------------------+  
  3. | ID | Hypervisor hostname         |  
  4. +----+-----------------------------+  
  5. | 1  | compute.konglingxian.com    |  
  6. | 2  | controller.konglingxian.com |  
  7. +----+-----------------------------+  
虚拟机正常运行,对虚拟机执行live-migration操作:

[plain]  view plain copy
  1. nova live-migration --block-migrate 6cd558d9-e924-4598-8e63-e86a20929bd9  

返回的异常信息如下:

[plain]  view plain copy
  1. {  
  2.     "badRequest": {  
  3.         "message": "Live migration of instance 6cd558d9-e924-4598-8e63-e86a20929bd9 to host controller failed",  
  4.         "code": 400  
  5.     }  
  6. }  


2、问题分析

先查看日志中的异常堆栈:

[plain]  view plain copy
  1. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions Traceback (most recent call last):  
  2. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  3. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/dist-packages/nova/openstack/common/rpc/amqp.py", line 430, in _process_data  
  4. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     rval = self.proxy.dispatch(ctxt, version, method, **args)  
  5. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  6. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/dist-packages/nova/openstack/common/rpc/dispatcher.py", line 133, in dispatch  
  7. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     return getattr(proxyobj, method)(ctxt, **kwargs)  
  8. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  9. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/dist-packages/nova/scheduler/manager.py", line 117, in live_migration  
  10. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     context, ex, {})  
  11. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  12. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__  
  13. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     self.gen.next()  
  14. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  15. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/dist-packages/nova/scheduler/manager.py", line 96, in live_migration  
  16. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     block_migration, disk_over_commit)  
  17. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  18. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/dist-packages/nova/scheduler/driver.py", line 196, in schedule_live_migration  
  19. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     ignore_hosts)  
  20. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  21. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/dist-packages/nova/scheduler/driver.py", line 272, in _live_migration_dest_check  
  22. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     filter_properties)[0]  
  23. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  24. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/dist-packages/nova/scheduler/filter_scheduler.py", line 146, in select_hosts  
  25. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     request_spec, filter_properties, instance_uuids)]  
  26. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  27. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/dist-packages/nova/scheduler/filter_scheduler.py", line 336, in _schedule  
  28. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     filter_properties)  
  29. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  30. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/dist-packages/nova/scheduler/host_manager.py", line 342, in get_filtered_hosts  
  31. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     hosts, filter_properties)  
  32. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  33. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/dist-packages/nova/filters.py", line 53, in get_filtered_objects  
  34. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     return list(objs)  
  35. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  36. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/dist-packages/nova/filters.py", line 39, in filter_all  
  37. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     if self._filter_one(obj, filter_properties):  
  38. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  39. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/dist-packages/nova/scheduler/filters/__init__.py", line 30, in _filter_one  
  40. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     return self.host_passes(obj, filter_properties)  
  41. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  42. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   File "/usr/lib/python2.7/dist-packages/nova/scheduler/filters/image_props_filter.py", line 78, in host_passes  
  43. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions     image_props = spec.get('image', {}).get('properties', {})  
  44. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  45. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions AttributeError: 'NoneType' object has no attribute 'get'  
  46. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  47. 2013-07-10 15:07:44.979 32348 TRACE nova.api.openstack.compute.contrib.admin_actions   
  48. 2013-07-10 15:07:44 INFO [nova.api.openstack.wsgi 673] [32348] HTTP exception thrown: Live migration of instance 6cd558d9-e924-4598-8e63-e86a20929bd9 to another host failed  

原来问题出在调度上,日志说的很明显了,是在image_props_filter中出现异常,spec.get('image', {})返回了None,导致python异常。那么spec.get('image', {})为什么返回None呢?从代码追溯一下spec中的image属性从何而来:

[python]  view plain copy
  1. if not instance_ref['image_ref']:  
  2.     image = None  
  3. else:  
  4.     image = self.image_service.show(context,  
  5.                                     instance_ref['image_ref'])  
  6. request_spec = {'instance_properties': instance_ref,  
  7.                 'instance_type': instance_type,  
  8.                 'instance_uuids': [instance_ref['uuid']],  
  9.                 'image': image}  
再回头看一下虚拟机信息,发现这个虚拟机是一个后端卷启动的虚拟机(boot from volume),至此,问题根因分析清楚。


3、问题解决

有两种解决方法:
1)修改在线迁移虚拟机的命令参数,强制指定目的主机,跳过schedule的阶段,改成如下(注意,如果是后端卷启动,就不能加--block-migrate参数,详细原因请参见:http://blog.csdn.net/lynn_kong/article/details/9186201):
[plain]  view plain copy
  1. nova live-migration 6cd558d9-e924-4598-8e63-e86a20929bd9 compute  
2)修改Nova的配置项scheduler_default_filters(默认配置是['RetryFilter', 'AvailabilityZoneFilter', 'RamFilter', 'ComputeFilter', 'ComputeCapabilitiesFilter', 'ImagePropertiesFilter']),将其中的ImagePropertiesFilter删除,重启nova-scheduler进程后再次执行迁移,成功。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值