背景:
注意,这个文件中的volume都是已经被attach了的,没有attach的volume不会在这个文件夹(针对lvm是这样,但nfs不是)
描述 | 详细 |
---|
- 向 cinder-api 发送 detach 请求
- 客户(可以是 OpenStack 最终用户,也可以是其他程序)向 cinder-api 发送请求:“请 detach 指定 instance 上的 volume。”
- 这里我们将 detach instance “c1”上的 volume “vol-1” 进入 GUI 操作菜单Project -> Volumes -> Volumes。选择 volume “vol-1”,点击“Manage Attachments”。点击 “Detach Volume”。
| ![paste-307214715715587.jpg](http://zhaolei.xuexihaike.com/paste-307214715715587.jpg) |
- 查看cinder-api日志
|
|
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] http://172.16.1.17/volume/v3/51743f081cb7477f9a1f4ccdf6490d8e /volumes/f0a54ac7-5423-4794-8883-d753f6a903cd/action
|
|
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: {"": null}
{{(pid=31313) get_method /opt/stack/cinder/cinder/api/openstack/wsgi.py:985
|
|
- cinder-api 发送消息
- cinder-api 发送消息 detach 消息。cinder-api 没有打印发送消息的日志,只能通过源代码查看 /opt/stack/cinder/cinder/volume/api.py,方法为 detach。
| ![paste-309310659756035.jpg](http://zhaolei.xuexihaike.com/paste-309310659756035.jpg) |
- nova-compute detach volume
- 查看计算节点上的n-cpu日志
|
|
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]
|
|
- 调用os-brick模块来detach volume
|
|
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]
{{(pid=5685) disconnect_volume /opt/stack/nova/nova/virt/libvirt/volume/iscsi.py:72}
|
|
- 具体有下面几个步骤:
- 将缓存中的数据 Flush 到 volume
|
|
Jun 20 17:05:33 compute nova-compute[5685]: DEBUG os_brick.initiator.linuxscsi
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin] {{(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.实际操作 |
- 删除计算节点上 volume 对应的 SCSI 设备sda
|
|
Jun 20 17:05:33 compute nova-compute[5685]: DEBUG os_brick.initiator.linuxscsi
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin] /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
|
|
Jun 20 17:05:33 compute nova-compute[5685]: DEBUG os_brick.initiator.linuxscsi
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin]
{{(pid=5685) wait_for_volumes_removal /usr/local/lib/python2.7/dist-packages/os_brick/initiator/linuxscsi.py:84
|
|
Jun 20 17:05:33 compute nova-compute[5685]: DEBUG os_brick.initiator.linuxscsi
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin]
{{(pid=5685) wait_for_volumes_removal /usr/local/lib/python2.7/dist-packages/os_brick/initiator/linuxscsi.py:93
|
|
- 通过 iscsiadm 的 logout,delete 操作断开与 iSCSI target 的连接
|
|
Jun 20 17:05:33 compute nova-compute[5685]: DEBUG os_brick.initiator.connectors.iscsi
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin] : stdout=Logging out of session ...
|
|
Jun 20 17:05:33 compute nova-compute[5685]: DEBUG os_brick.initiator.connectors.iscsi
[None req-8db7c86d-8c94-42bc-a2cd-923051715351 admin admin] : stdout= stderr=
{{(pid=5685) _run_iscsiadm /usr/local/lib/python2.7/dist-packages/os_brick/initiator/connectors/iscsi.py:973
|
|
- cinder-volume 删除 target
- 存储节点 cinder-volume 通过 tgt-admin 命令删除 volume 对应的 target。查看c-vol日志
|
|
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] for Volume ID: f0a54ac7-5423-4794-8883-d753f6a903cd
|
|
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 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
|
|
- 至此 detach volume 操作已经完成,GUI 也会更新 volume 的 detach 信息
- 通过在计算节点输入virsh edit instance-00000001查看更新后的 XML,发现/dev/vdb设备已经删除
| ![paste-330729661661187.jpg](http://zhaolei.xuexihaike.com/paste-330729661661187.jpg) |