08.存储Cinder→5.场景学习→04.Detach Volume

背景:

注意,这个文件中的volume都是已经被attach了的,没有attach的volume不会在这个文件夹(针对lvm是这样,但nfs不是)


描述 详细
  1. 向 cinder-api 发送 detach 请求
    1. 客户(可以是 OpenStack 最终用户,也可以是其他程序)向 cinder-api 发送请求:“请 detach 指定 instance 上的 volume。”
    2. 这里我们将 detach instance “c1”上的 volume “vol-1” 进入 GUI 操作菜单Project -> Volumes -> Volumes。选择 volume “vol-1”,点击“Manage Attachments”。点击 “Detach Volume”。
  1. 查看cinder-api日志
1
2
3
4
5
Jun 20 17:05:32 controller devstack@c-api.service[31309]: 
INFO cinder.api.openstack.wsgi
[req-8db7c86d-8c94-42bc-a2cd-923051715351 req-7... admin admin]
POST http://172.16.1.17/volume/v3/51743f081cb7477f9a1f4ccdf6490d8e
/volumes/f0a54ac7-5423-4794-8883-d753f6a903cd/action
1
2
3
4
5
Jun 20 17:05:32 controller devstack@c-api.service[31309]: 
DEBUG cinder.api.openstack.wsgi
[req-8db7c86d-8c94-42bc-a2cd-923051715351 req-... admin admin]
Action body: {"os-begin_detaching": null}
{{(pid=31313) get_method /opt/stack/cinder/cinder/api/openstack/wsgi.py:985
  1. cinder-api 发送消息
    1. cinder-api 发送消息 detach 消息。cinder-api 没有打印发送消息的日志,只能通过源代码查看 /opt/stack/cinder/cinder/volume/api.py,方法为 detach。
  1. nova-compute detach volume
    1. 查看计算节点上的n-cpu日志
1
2
3
4
5
Jun 20 17:05:33 compute nova-compute[5685]: 
INFO nova.compute.manager
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin]
[instance: 0af39618-5d8c-4fc8-bb44-781246bff6dd]
Detaching volume f0a54ac7-5423-4794-8883-d753f6a903cd
  1. 调用os-brick模块来detach volume
1
2
3
4
5
Jun 20 17:05:33 compute nova-compute[5685]: 
DEBUG nova.virt.libvirt.volume.iscsi
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin]
[instance: 0af39618-5d8c-4fc8-bb44-781246bff6dd] calling os-brick to detach iSCSI Volume
{{(pid=5685) disconnect_volume /opt/stack/nova/nova/virt/libvirt/volume/iscsi.py:72}
  1. 具体有下面几个步骤:
    1. 将缓存中的数据 Flush 到 volume
1
2
3
4
5
Jun 20 17:05:33 compute nova-compute[5685]: 
DEBUG os_brick.initiator.linuxscsi
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin]
Flushing IO for device /dev/sda {{(pid=5685)
flush_device_io /usr/local/lib/python2.7/dist-packages/os_brick/initiator/linuxscsi.py:313
target vdb的souce是/dev/sda,就是要 attach 的 volume参考见08.存储Cinder→5.场景学习→3.Attach Volume→2.实际操作
  1. 删除计算节点上 volume 对应的 SCSI 设备sda
1
2
3
4
5
Jun 20 17:05:33 compute nova-compute[5685]: 
DEBUG os_brick.initiator.linuxscsi
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin]
Remove SCSI device /dev/sda with /sys/block/sda/device/delete
{{(pid=5685) remove_scsi_device /usr/local/lib/python2.7/dist-packages/os_brick/initiator/linuxscsi.py:76
1
2
3
4
5
Jun 20 17:05:33 compute nova-compute[5685]: 
DEBUG os_brick.initiator.linuxscsi
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin]
Checking to see if SCSI volumes sda have been removed.
{{(pid=5685) wait_for_volumes_removal /usr/local/lib/python2.7/dist-packages/os_brick/initiator/linuxscsi.py:84
1
2
3
4
5
Jun 20 17:05:33 compute nova-compute[5685]: 
DEBUG os_brick.initiator.linuxscsi
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin]
SCSI volumes sda have been removed.
{{(pid=5685) wait_for_volumes_removal /usr/local/lib/python2.7/dist-packages/os_brick/initiator/linuxscsi.py:93
  1. 通过 iscsiadm 的 logout,delete 操作断开与 iSCSI target 的连接
1
2
3
4
Jun 20 17:05:33 compute nova-compute[5685]: 
DEBUG os_brick.initiator.connectors.iscsi
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin]
iscsiadm ('--logout',): stdout=Logging out of session ...
1
2
3
4
5
Jun 20 17:05:33 compute nova-compute[5685]: 
DEBUG os_brick.initiator.connectors.iscsi
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin]
iscsiadm ('--op', 'delete'): stdout= stderr=
{{(pid=5685) _run_iscsiadm /usr/local/lib/python2.7/dist-packages/os_brick/initiator/connectors/iscsi.py:973
  1. cinder-volume 删除 target
    1. 存储节点 cinder-volume 通过 tgt-admin 命令删除 volume 对应的 target。查看c-vol日志
1
2
3
4
Jun 20 17:05:34 controller cinder-volume[304]: 
INFO cinder.volume.targets.tgt
[req-8db7c86d-8c94-42bc-a2cd-923051715351 req-47b18f6e-2c48-4977-ac20-803ff3125bd5 admin None]
Removing iscsi_target for Volume ID: f0a54ac7-5423-4794-8883-d753f6a903cd
1
2
3
4
5
6
Jun 20 17:05:34 controller cinder-volume[304]: 
DEBUG oslo_concurrency.processutils
[req-8db7c86d-8c94-42bc-a2cd-923051715351 req-47b18f6e-2c48-4977-ac20-803ff3125bd5 admin None]
CMD "sudo cinder-rootwrap /etc/cinder/rootwrap.conf tgt-admin --force --delete
iqn.2010-10.org.openstack:volume-f0a54ac7-5423-4794-8883-d753f6a903cd" returned: 0 in 0.273s
{{(pid=460) execute /usr/local/lib/python2.7/dist-packages/oslo_concurrency/processutils.py:409
  1. 至此 detach volume 操作已经完成,GUI 也会更新 volume 的 detach 信息
    1. 通过在计算节点输入virsh edit instance-00000001查看更新后的 XML,发现/dev/vdb设备已经删除

猜你喜欢

转载自www.cnblogs.com/LeisureZhao/p/11185470.html
0条评论
添加一条新回复