containers / docker-lvm-plugin

Docker volume plugin for LVM volumes
GNU Lesser General Public License v3.0
155 stars 64 forks source link

Can't remove docker volume if lvm volume is missing #88

Closed LeMyst closed 4 years ago

LeMyst commented 4 years ago

Hello,

Du to some circumstances (manual deletion), my lvm volume is now missing and I can't remove it with "docker volume rm -f".

I can do a "sudo lvcreate -n mylvvolumedeleted -L 1 myvg" to recreate a temporary lvm volume, but a more comprehensive message than "Error response from daemon: remove mylvvolumedeleted: VolumeDriver.Remove: error removing volume" would be better, and maybe the force option remove the docker volume when the lv volume is missing (for my case).

https://github.com/containers/docker-lvm-plugin/blob/994a35e5405e50ec141300aec4645b23e8270865/utils.go#L23

shishir-a412ed commented 4 years ago

@LeMyst

We already have --force in lvremove

I tried to reproduce this:

  1. Create an lvm volume foobar: docker volume create -d lvm --opt size=1G foobar
  2. docker volume ls
[root@fedora32 docker-lvm-plugin]# docker volume ls
DRIVER              VOLUME NAME
lvm                 foobar
  1. Remove the underlying volume using lvremove: lvremove -y vg1/foobar

  2. docker volume rm foobar

[root@fedora32 docker-lvm-plugin]# docker volume rm foobar
Error: No such volume: foobar

The error is not coming from lvremove but from here

When you do docker volume rm foobar, docker first calls Get API to get information on the volume. In the Get call, getVolumeCreationDateTime is called which relies on lvdisplay

lvdisplay will fail because of the missing volume.

While I agree, the error message could be improved, this is not related to lvremove. Let me see if I can add some loggers (error message) to improve debugging.