openstack resize不会改变磁盘大小

针对OpenStack N版测试,存储使用的是共享存储。

发生磁盘扩展的程序代码在/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py: finish_migration函数,具体如下:
7353         # Resize root disk and a single ephemeral disk called disk.local
7354         # Also convert raw disks to qcow2 if migrating to host which uses
7355         # qcow2 from host which uses raw.
7356         # TODO(mbooth): Handle resize of multiple ephemeral disks, and
7357         #               ephemeral disks not called disk.local.
7358         disk_info = jsonutils.loads(disk_info)
7359         LOG.debug("pdx98 disk info %s.", disk_info)  #这是我加的日志
7360         for info in disk_info:
7361             path = info['path']
7362             disk_name = os.path.basename(path)
7363
7364             size = self._disk_size_from_instance(instance, disk_name)
7365             LOG.debug("pdx98 resize instance %s.", resize_instance)
7366             if resize_instance:
7367                 image = imgmodel.LocalFileImage(path, info['type'])
7368                 self._disk_resize(image, size)
 
finish_migration调用了_disk_resize函数
7318         LOG.debug("pdx98 disk resize size is %s.", size) #这是我加的日志
7319         if size:
7320             LOG.debug("pdx98 ready to extend.")
#这是我加的日志
7321             disk_api.extend(image, size) #这是调用的扩展接口
7322
 
测试了两次resize,测试结果如下,说明jsonutils.loads(disk_info)返回的disk信息都是空的,导致不会进行磁盘扩展
-> # grep "pdx98" -Inr *
nova-compute.log:127:2020-06-03 15:21:15.340 3298 DEBUG nova.virt.libvirt.driver [req-5c1e50fe-c0f6-46b4-9d5e-22aadf9c8089 8215d24fbde54451b2e04bbdcb7b96bb 8ebc3a28eb124638a8c7dedcbbafe8f3 - - -] pdx98 disk info []. finish_migration /usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py:7359
 
root@server223 [03:22:15 PM] [/var/log/nova]
-> # grep "pdx98" -Inr *
nova-compute.log:127:2020-06-03 15:21:15.340 3298 DEBUG nova.virt.libvirt.driver [req-5c1e50fe-c0f6-46b4-9d5e-22aadf9c8089 8215d24fbde54451b2e04bbdcb7b96bb 8ebc3a28eb124638a8c7dedcbbafe8f3 - - -] pdx98 disk info []. finish_migration /usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py:7359
 
 
2 网络调查
"resize与migrate底层接口一致,假若前端传入了新的flavor,则是resize,该该新的flavor传入底层。迁移传入底层的flavor则为自身实例相同的flavor。底层根据传入进来的flavor参数走相同的逻辑。resize与migrate的区别是在迁移的同时,是否改变虚拟机的flavor。"
上面的话来自下面的链接,migrate是不会改变磁盘大小的,所以resize也根本不会改变磁盘大小。

————————————————
原文链接:https://blog.csdn.net/tantexian/java/article/details/41444461

posted @ 2020-06-03 15:44  kissrule  阅读(570)  评论(0编辑  收藏  举报