yp-engineering / rbd-docker-plugin

Ceph RBD docker volume driver plugin.
MIT License
102 stars 70 forks source link

Device name isn't getting returned from mapImage #19

Closed deanpemberton closed 8 years ago

deanpemberton commented 8 years ago

'rbd map' doesn't return the mapped device name.

# rbd showmapped
# rbd map --id docker --pool docker bar
# rbd showmapped
id pool   image snap device    
0  docker bar   -    /dev/rbd0 

This means that the name is never returned to the mapImage function and therefore unavailable to later functions.

     return sh("rbd", "map", "--id", d.user, "--pool", pool, imagename)

Here is the output showing what happens when the device name isn't returned by mapImage

RBD_DOCKER_PLUGIN_DEBUG=1 ./rbd-docker-plugin --user=docker --pool=docker --create
...
rbd-volume-plugin: 2016/01/16 21:35:08 driver.go:911: DEBUG: sh CMD: &{"/usr/bin/rbd" ["rbd" "map" "--id" "docker" "--pool" "docker" "bar"] [] "" <nil> <nil> <nil> [] %!q(*syscall.SysProcAttr=<nil>) %!q(*os.Process=<nil>) "<nil>" ?reflect.Value? %!q(bool=false) [] [] [] [] %!q(chan error=<nil>)}
rbd-volume-plugin: 2016/01/16 21:35:08 driver.go:911: DEBUG: sh CMD: &{"/sbin/blkid" ["blkid" "-o" "value" "-s" "TYPE" ""] [] "" <nil> <nil> <nil> [] %!q(*syscall.SysProcAttr=<nil>) %!q(*os.Process=<nil>) "<nil>" ?reflect.Value? %!q(bool=false) [] [] [] [] %!q(chan error=<nil>)}
rbd-volume-plugin: 2016/01/16 21:35:08 driver.go:321: WARN: unable to detect RBD Image(bar) fstype: exit status 2
rbd-volume-plugin: 2016/01/16 21:35:08 driver.go:911: DEBUG: sh CMD: &{"/bin/mount" ["mount" "-t" "xfs" "" "/var/lib/docker-volumes/rbd/docker/bar"] [] "" <nil> <nil> <nil> [] %!q(*syscall.SysProcAttr=<nil>) %!q(*os.Process=<nil>) "<nil>" ?reflect.Value? %!q(bool=false) [] [] [] [] %!q(chan error=<nil>)}
rbd-volume-plugin: 2016/01/16 21:35:08 driver.go:339: ERROR: mounting device() to directory(/var/lib/docker-volumes/rbd/docker/bar): exit status 32
rbd-volume-plugin: 2016/01/16 21:35:08 driver.go:803: INFO: unlockImage(docker/bar, docker1)
rbd-volume-plugin: 2016/01/16 21:35:08 driver.go:911: DEBUG: sh CMD: &{"/usr/bin/rbd" ["rbd" "unmap" ""] [] "" <nil> <nil> <nil> [] %!q(*syscall.SysProcAttr=<nil>) %!q(*os.Process=<nil>) "<nil>" ?reflect.Value? %!q(bool=false) [] [] [] [] %!q(chan error=<nil>)}
rbd-volume-plugin: 2016/01/16 21:35:08 driver.go:401: INFO: Unmount(bar)
rbd-volume-plugin: 2016/01/16 21:35:08 driver.go:592: DEBUG: parseImagePoolNameSize: "bar": ["bar" "" "" "bar" "" ""]
rbd-volume-plugin: 2016/01/16 21:35:08 driver.go:419: WARN: Volume is not in known mounts: will attempt limited Unmount: bar
rbd-volume-plugin: 2016/01/16 21:35:08 driver.go:911: DEBUG: sh CMD: &{"/bin/umount" ["umount" "/dev/rbd/docker/bar"] [] "" <nil> <nil> <nil> [] %!q(*syscall.SysProcAttr=<nil>) %!q(*os.Process=<nil>) "<nil>" ?reflect.Value? %!q(bool=false) [] [] [] [] %!q(chan error=<nil>)}
rbd-volume-plugin: 2016/01/16 21:35:08 driver.go:434: ERROR: unmounting device(/dev/rbd/docker/bar): exit status 1
rbd-volume-plugin: 2016/01/16 21:35:08 driver.go:911: DEBUG: sh CMD: &{"/usr/bin/rbd" ["rbd" "unmap" "/dev/rbd/docker/bar"] [] "" <nil> <nil> <nil> [] %!q(*syscall.SysProcAttr=<nil>) %!q(*os.Process=<nil>) "<nil>" ?reflect.Value? %!q(bool=false) [] [] [] [] %!q(chan error=<nil>)}
rbd-volume-plugin: 2016/01/16 21:35:09 driver.go:803: INFO: unlockImage(docker/bar, docker1)
rbd-volume-plugin: 2016/01/16 21:35:09 driver.go:450: ERROR: unlocking RBD image(bar): RBD image not found

I've tested this on Debian Wheezy and Ubuntu 14.04.

I've got a fix which I'll make a pull request for in a second which seems to fix it. More than willing to admit it's not the most glamourous way to handle it though

rbd-volume-plugin: 2016/01/16 22:26:01 driver.go:924: DEBUG: sh CMD: &{"/usr/bin/rbd" ["rbd" "map" "--id" "docker" "--pool" "docker" "bar"] [] "" <nil> <nil> <nil> [] %!q(*syscall.SysProcAttr=<nil>) %!q(*os.Process=<nil>) "<nil>" ?reflect.Value? %!q(bool=false) [] [] [] [] %!q(chan error=<nil>)}
rbd-volume-plugin: 2016/01/16 22:26:01 driver.go:881: DEBUG: getRBDDeviceName CMD: "rbd showmapped | grep bar | awk '{print $5}' | sed -e 's/$//'"
rbd-volume-plugin: 2016/01/16 22:26:01 driver.go:924: DEBUG: sh CMD: &{"/sbin/blkid" ["blkid" "-o" "value" "-s" "TYPE" "/dev/rbd0"] [] "" <nil> <nil> <nil> [] %!q(*syscall.SysProcAttr=<nil>) %!q(*os.Process=<nil>) "<nil>" ?reflect.Value? %!q(bool=false) [] [] [] [] %!q(chan error=<nil>)}
rbd-volume-plugin: 2016/01/16 22:26:01 driver.go:924: DEBUG: sh CMD: &{"/bin/mount" ["mount" "-t" "xfs" "/dev/rbd0" "/var/lib/docker-volumes/rbd/docker/bar"] [] "" <nil> <nil> <nil> [] %!q(*syscall.SysProcAttr=<nil>) %!q(*os.Process=<nil>) "<nil>" ?reflect.Value? %!q(bool=false) [] [] [] [] %!q(chan error=<nil>)}
hekaldama commented 8 years ago

Looking now.

hekaldama commented 8 years ago

I have tested this to not be the case on CentOS 7.1* at least with the following:

# cat /etc/redhat-release && uname -r && ceph --version
CentOS Linux release 7.1.1503 (Core) 
3.10.0-229.11.1.el7.x86_64
ceph version 0.94.2 (5fb85614ca8f354284c713a2f9c610860720bbf3)
# rbd showmapped
# rbd map rbd/foo
/dev/rbd0
# rbd unmap /dev/rbd0
# rbd map --id admin --pool rbd foo
/dev/rbd0

Can you attach your version of ceph you are running and any pertinent system info?

deanpemberton commented 8 years ago

cat /etc/debian_version && uname -r && ceph --version

jessie/sid 3.16.0-57-generic ceph version 0.80.10 (ea6c958c38df1216bf95c927f143d8b13c4a9e70)

Let me try with a later version of ceph. Thats the latest in the 14.04 repo, so I'll get something directly and retry.

apt-cache policy ceph-common

ceph-common: Installed: 0.80.10-0ubuntu1.14.04.3 Candidate: 0.80.10-0ubuntu1.14.04.3 Version table: *\ 0.80.10-0ubuntu1.14.04.3 0 500 http://ftp.X/mirrors/linux/ubuntu/packages/ trusty-updates/main amd64 Packages 100 /var/lib/dpkg/status 0.79-0ubuntu1 0 500 http://ftp.X/mirrors/linux/ubuntu/packages/ trusty/main amd64 Packages

hekaldama commented 8 years ago

Maybe just change the PR to include logic to only call getRBDDeviceName if line 832 doesn't return the device? I will put comments on the commit.

deanpemberton commented 8 years ago

That would work.

On Friday, 22 January 2016, Adam Avilla notifications@github.com wrote:

Maybe just change the PR to include logic to only call getRBDDeviceName if line 832 https://github.com/deanpemberton/rbd-docker-plugin/commit/10300b88fa02ad4419b4426e532847520cfa22d1#diff-749da71b40f8ff06fc9e78ce917b0cceR832 doesn't return the device?

— Reply to this email directly or view it on GitHub https://github.com/yp-engineering/rbd-docker-plugin/issues/19#issuecomment-173665986 .

Regards,

Dean

hekaldama commented 8 years ago

@deanpemberton how did it go? Did you end up just updating ceph and using this as is?