无法删除 Cinder 卷并显示错误消息 "image still has watchers"

Cannot delete Cinder volume with error message "image still has watchers"

I 运行 Openstack cinderceph 作为其存储后端。当我偶尔尝试删除其中一个 cinder-volume 时,它​​失败了。

所以我转而使用rbd命令来解决这个问题,下面是命令打印的错误信息:rbd rm ${pool}/${volume-id}

rbd: error: image still has watchers
This means the image is still open or the client using it crashed. Try again after closing/unmapping it or waiting 30s for the crashed client to timeout.

然后rbd status ${pool}/${volume-id}显示

Watchers:
watcher=172.18.0.1:0/523356342 client.230016780 cookie=94001004445696

我很困惑为什么watcher会卡在卷上导致无法删除卷,是什么原因还是我做错了什么?

在这种情况下如何删除卷?

我找到了解决这个问题的方法,概念是使用ceph osd blacklist将观察者添加到黑名单,然后该卷将变为可移动,删除后,将观察者从黑名单中移除。

  1. 将观察者加入黑名单
$ ceph osd blacklist add 172.18.0.1:0/523356342
blacklisting 172.18.0.1:0/523356342
  1. 检查状态并删除卷
$ rbd status ${pool}/${volume-id}
Watchers: none

$ rbd rm ${pool}/${volume-id}
Removing image: 100% complete...done.
  1. 将观察者从黑名单中移除
$ ceph osd blacklist rm 172.18.0.1:0/523356342
un-blacklisting 172.18.0.1:0/523356342

就这些了,但仍在寻找根本原因。