-
Notifications
You must be signed in to change notification settings - Fork 559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add block supports to rbd driver #97
Conversation
pkg/rbd/nodeserver.go
Outdated
if notMnt { | ||
return nil, status.Error(codes.NotFound, "Volume not mounted") | ||
} | ||
|
||
devicePath, cnt, err := mount.GetDeviceNameFromMount(ns.mounter, targetPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a result of discussion in CSI WG, csi driver needs bind mount device to target path for block volume case.
However, on unpublish, above code doesn't seem to return a proper devicePath for block volume.
Because mount command returns devtmpfs
instead of devicePath, if the block volume is bind mounted.
On the other hand, findmnt
will return an information on devicePath.
Are there any good ways to utilize findmnt
command for this purpose inside csi driver, here?
# touch /tmp/dev
# mount -o bind /dev/rbd0 /tmp/dev
# mount | grep /tmp/dev
devtmpfs on /tmp/dev type devtmpfs (rw,nosuid,seclabel,size=16460544k,nr_inodes=4115136,mode=755)
# findmnt -n -o SOURCE --target /tmp/dev
devtmpfs[/rbd0]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case, you can use the block's major and minor number to find the device path.
https://www.kernel.org/doc/Documentation/admin-guide/devices.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#mount -o bind /dev/sdc /tmp/dev
# ls -l /tmp/dev
brw-rw----. 1 root disk 8, 32 Nov 2 09:36 /tmp/dev
# so the major number is 8, minor number is 32, you can also get them from stat
# then find the same major and minor number in /dev
# ls -l /dev/sd*
brw-rw----. 1 root disk 8, 0 Oct 8 19:00 /dev/sda
brw-rw----. 1 root disk 8, 1 Oct 8 19:00 /dev/sda1
brw-rw----. 1 root disk 8, 2 Oct 8 19:00 /dev/sda2
brw-rw----. 1 root disk 8, 16 Oct 8 19:00 /dev/sdb
brw-rw----. 1 root disk 8, 17 Oct 8 19:00 /dev/sdb1
brw-rw----. 1 root disk 8, 18 Oct 8 19:00 /dev/sdb2
brw-rw----. 1 root disk 8, 32 Nov 2 09:36 /dev/sdc
I made a quick dirty hack to k8s's util side to make If there's no easy better way or this kind of change will also benefit to k8s, I will open an issue for k8s and make a PR for handling device bind mount. (Actually, I'm very new to these mount code, I really need someone's help.) Any comments on this?
|
@@ -24,6 +24,9 @@ rules: | |||
- apiGroups: [""] | |||
resources: ["events"] | |||
verbs: ["list", "watch", "create", "update", "patch"] | |||
- apiGroups: [""] | |||
resources: ["endpoints"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does provisioner need endpoints?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I retest with deleting this and confirmed that this isn't necessary, so I removed it.
I suspect that I enabled leader election in the previous tests.
pkg/rbd/nodeserver.go
Outdated
st, err := os.Stat(targetPath) | ||
if err != nil { | ||
if os.IsNotExist(err) { | ||
return nil, status.Error(codes.NotFound, "targetPath not mounted") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: targetPath not exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed as suggested.
pkg/rbd/nodeserver.go
Outdated
return nil, status.Error(codes.Internal, err.Error()) | ||
} | ||
} | ||
if !st.Mode().IsRegular() { | ||
return nil, status.Error(codes.Internal, "targetPath is not regular file") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could the target path be a sym link? if so, should the sym link be resolved first and check if it is a regular file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not be a symlink and it should be a regular file that CO create just for bind mount the device. So, keeping it as is.
Thank you for your comments. Fixed as suggested. If you find any other ways to resolve bind mounted device, please let me know it. (I guess that device number matching would also require getting information from node as it is done via findmount.) |
As a result of investigation, it seems that devicePath could be resolved inside csi-rbdplugin, just by executing findmnt command there. So, 4aa6646 moves resolving bind mount logic from k8s to csi-rbdplugin. |
@@ -112,12 +112,6 @@ func (m *execMounter) GetDeviceNameFromMount(mountPath, pluginDir string) (strin | |||
return m.wrappedMounter.GetDeviceNameFromMount(mountPath, pluginDir) | |||
} | |||
|
|||
// ResolveBindMountedBlockDevice resolves a block device bind mounted on mountPath by calling findmnt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how did you update vendor packages? wouldn't Gopkg.lock get updated too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I directly updated them as a dirty hack, which should be fixed before merge.
As commented above, this dirty hack won't be necessary if 4aa6646 makes sense.
In 1d770c6, I updated only rbd codes for csi v1.0.0 spec, to continue discussion on block volume related function in csi external provisioner (kubernetes-csi/external-provisioner#135). So, cephfs codes have issues in this commit. I would expect that csi rbd driver and cephfs driver codes for csi v1.0.0 will be merged in a separate PR, so that this PR can only focus on block volume feature for csi rbd driver. |
@mkimuram got it, thanks for the update and hard work! |
since csi v1 is already merged, I'll pick up the block volume support commits and create a new PR |
superseded by #132 |
sync downstream devel branch with upstream
This PR is to add block supports to rbd driver.
This won't be ready to be merge until below discussions completed.
kubernetes/kubernetes#68635