08.存儲Cinder→5.場景學習→04.Detach Volume

背景:html

注意,這個文件中的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設備已經刪除
相關文章
相關標籤/搜索