Change:
} s := dstrings.Split(sourceName, "-image-") if len(s) != 2 { <del> return nil, fmt.Errorf("sourceName %s wrong, should be pool+"-image-"+imageName", sourceName) </del> <ins> // The mountPath parameter is the volume mount path for a specific pod, its format // is /var/lib/kubelet/pods/{podUID}/volumes/{volumePluginName}/{volumeName}. // mounter.GetDeviceNameFromMount will find the device path(such as /dev/rbd0) by // mountPath first, and then try to find the global device mount path from the mounted // path list of this device. sourceName is extracted from this global device mount path. // mounter.GetDeviceNameFromMount expects the global device mount path conforms to canonical // format: /var/lib/kubelet/plugins/kubernetes.io/rbd/mounts/{pool}-image-{image}. // If this assertion failed, it means that the global device mount path is created by // the deprecated format: /var/lib/kubelet/plugins/kubernetes.io/rbd/rbd/{pool}-image-{image}. // So we will try to check whether this old style global device mount path exist or not. // If existed, extract the sourceName from this old style path, otherwise return an error. glog.V(3).Infof("SourceName %s wrong, fallback to old format", sourceName) sourceName, err = plugin.getDeviceNameFromOldMountPath(mounter, mountPath) if err != nil { return nil, err } s = dstrings.Split(sourceName, "-image-") if len(s) != 2 { return nil, fmt.Errorf("sourceName %s wrong, should be pool+"-image-"+imageName", sourceName) } </ins> } rbdVolume := &v1.Volume{ Name: volumeName,

Discussion:
<!-- This form is for bug reports and feature requests ONLY! If you're looking for help check and the . --Is this a BUG REPORT or FEATURE REQUEST?: What happened: The method for ceph rbd volume plugin generates the path with code as follows: So the device mount path's format will be: , this implementation has two problems: with other volume plugins, as all the other plugins return , see as an example. method of ceph rbd plugin is not working properly, because rbd plugin uses method to find the device mount path(just like all the other plugins do), and method assumes the device mount path's format is (see ). What you expected to happen: The device mount path of rbd plugin should be . Anything else we need to know?: Do we have any reason for this design? If not, I will submit a PR to fix this, the adjusted method maybe look like this: /sig storage
/assign
nice catch There are two ways to fix this: Change mount path. But this will introduce compatibility issues during upgrade. Use , instead of to replace PR welcome
cc
Hi , there is a difference between and : returns the device path, such as , and returns the device mounted path, such as . What we really want is the second one, as we need to find the pool and image name. So we can't just simply replace with . Maybe we can find the mounted path specially for rbd plugin, use , the code looks like this:
thanks let make a forward moving plan: fix and append to the global path keep in . If no path is found, fall back to old path scheme using your code
Nice idea , I've submit a PR for this, PTAL.
I've checked and the reason is that I tested with the old release branch, the has been changed with in mount path, and causes the problem. thanks for your PR
i read again. There is another return path . So in rbd, the missing dir will not make into , but the second return should still give us the dir we need
You are right , indeed has two return path, but the second return still can't meet our needs. Because the parameter of is the mount path for a specific pod, such as , its format is , so will return the volume name. This volume name is returned by (see ), usually is the PV's name or the name specified in , both of these are not .