fentas/docker-volume-davfs

Files Removed from webdav path when removing volume

gimmeker opened this issue ยท 8 comments

When i delete a volume from docker, the files on webdav server are also deleted.
Is it possible to remove a volume without deleting the content of the webdav folder ?

You mean if you do a docker volume rm ... it's deleting files from your webdav endpoint?
๐Ÿค” This should not happen at all.
Can you clarify? Thanks ๐Ÿ™Œ

Yes thats exactly what happens. I have a backup of the volume but it takes some time to restore the volume. Yesterday i tested it again with docker volume rm -f . If i look on the webdav endpoint in the web interface i can see de folder being emptyed slowly. Also the docker rm -f syntax times out most likely because it takes to much time to delete files. I found there are 2 volumes with a diffrent name but the same path could this be an issue ?

Ok i tried reproduce the problem on a diffrent system. And there it works ok. Strange thing about the system where it doesnt work ok. Is that the mount points for those volumes are the same on the docker host. That isnt the case on the system where it works ok.

Machine that has that problem.
image

Machine that works ok.
image

๐Ÿค” wired. So the plugin does only an umount and removes the folder, I think.
Wouldn't know how this could happen. Guess we could update the repo from the latest version of sshd.

Well for time being i let these existing volumes remain it doesnt seem to affect newly created volumes only the volumes that already exist with the same id this way i can work around the problem and i am planning to remove all the volumes with the same and only recreate the ones i need i hope the solve the problem this way.

well, I don't think the deleting part when unmounted is happening from the plugin itself.
If you think you can solve that problem that way, feel free to close the issue. ๐Ÿฑ

For anyone who has this issue. We recently had a similar issue of data loss with the vieux/sshfs plugin. It seems the problem arises when:

  • n volume pointing to same location
  • one of these volume is currently in use
  • when removing the unused volume

a way to reproduce:

# 
mkdir -p /tmp/sshfs
echo "hello" > /tmp/sshfs/file
docker run --rm --publish=2222:22 -v /tmp/sshfs:/tmp/sshfs sickp/alpine-sshd:7.5-
r2

#
docker volume create -d vieux/sshfs -o sshcmd=root@localhost:/tmp/sshfs -o port=2222 -o password=root sshvolume-local
docker volume create -d vieux/sshfs -o sshcmd=root@localhost:/tmp/sshfs -o port=2222 -o password=root sshvolume-local2

#
docker run --rm -d -v sshvolume-local:/tmp/sshfs nginx

# Data loss!
docker volume rm sshvolume-local2
# Data loss!

One fix could be to replace os.RemoveAll by os.Remove
I have tried it successfully so far in this implementation : https://github.com/StudioEtrange/docker-volume-bindfs
which is a plugin built like sshfs plugin but with bindfs functionnality
see https://github.com/StudioEtrange/docker-volume-bindfs/blob/6a793cba0ef51443d67d54eeb170b7a4d7e86461/main.go#L268

(inspiration taken from https://github.com/ucphhpc/docker-volume-sshfs)