Azure / azurefile-dockervolumedriver

Docker Volume Driver for Azure File Service over SMB/CIFS :whale:
Apache License 2.0
169 stars 57 forks source link

remotepath throws error #63

Closed mrmunch closed 8 years ago

mrmunch commented 8 years ago

I have an Azure Storage account called mystorageaccount with a file share called myshare and a directory inside this share called mydir.

works: docker run -it -v $(docker volume create -d azurefile -o share=myshare):/data ubuntu

doesn't work: docker run -it -v $(docker volume create -d azurefile -o share=myshare -o remotepath=mydir):/data ubuntu I get:

docker: Error response from daemon: VolumeDriver.Mount: mount failed: exit status 1 output="mount.cifs: bad UNC (/mystorageaccount.file.core.windows.net/myshare/mydir)\n".

ahmetb commented 8 years ago

This looks interesting. I am not familiar with SMB and UNC paths myself. Does it work fine without the -o remotepath?

@zlatan any ideas if you see any issues with the UNC syntax, or how did it work for you?

mrmunch commented 8 years ago

Yes, as I wrote in the first command, it works when I don't use -o remotepath

zlatan commented 8 years ago

@ahmetalpbalkan I reproduced the problem. In current implementation 'remotepath' work with only one level of depth, @mrmunch have two.

mrmunch commented 8 years ago

@zlatan So the share already counts as one level of depth? But isn't remotepath always a subdir of share? So remotepath might never work atm?

ahmetb commented 8 years ago

Hmm is this like we're constructing a bad UNC or is this an unsupported feature?

williamayerst commented 8 years ago

I have done some more testing, and if 'remotepath' is used, on the first time the volume is created it errors. I appears the UNC path is missing a prepending '/'

ERROR: for busybox  Cannot start service busybox: VolumeDriver.Mount: mount failed: exit status 1
output="mount.cifs: bad UNC (/xxxx.file.core.windows.net/busybox/subdir)\n"

ERROR: for db  Cannot start service db: VolumeDriver.Mount: mount failed: exit status 1
output="mount.cifs: bad UNC (/xxxx.file.core.windows.net/postgres/data)\n"

Subsequently the volume object exists and so doesn't present any errors, it just doesn't work.

ahmetb commented 8 years ago

@zlatan I think I found a bug. This piece of code https://github.com/Azure/azurefile-dockervolumedriver/blob/81e6f45967b0caf3c8352ce207ee2356967325ba/driver.go#L306-L309 uses path.Join to append the remotepath into a string like //host/share.

However path.Join assumes // is redundant and simplifies the path by removing one of the slashes. https://play.golang.org/p/FFg_Iap2CQ

I will submit a fix.

ahmetb commented 8 years ago

@williamayerst @mrmunch can you please try v0.5.1-rc.0 binary? https://github.com/Azure/azurefile-dockervolumedriver/releases/tag/v0.5.1-rc.0

If it works for you I will tag and release it as v0.5.1. I appreciate your help, sorry for the inconvenience. I have no idea how this ever worked :)

williamayerst commented 8 years ago

Hurrah, I will check and let you know on Monday, thanks!

zlatan commented 8 years ago

@ahmetalpbalkan Yes, it's a bug.

mrmunch commented 8 years ago

@ahmetalpbalkan I can confirm it works now! I also tested it with remotepath=dir/subdir.

ahmetb commented 8 years ago

Thanks.