Unverified Commit 4562198a authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #56925 from wenjun93/fix_rbd

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. fix rbd volume ConstructVolumeSpec **What this PR does / why we need it**: 1. rbd plugin.ConstructVolumeSpec() construct volume spec with fake value, cause kubelet volume manager will create two volumesInUse in node Status. 2. change plugin.GetVolumeName(), create volumeName using rbd pool instead of monitors, because monitors is a group of IPs, which makes the volumeName too long. Also, this is to fit plugin.ConstructVolumeSpec() since makeGlobalPDName only uses rbd pool and image. ``` before fix: volumesAttached: - devicePath: "" name: kubernetes.io/rbd/[xxxxxxx:6789 xxxxxxxxx:6789]:volume-9a106847-4def-4d1e-9603-4c7099b22a31 volumesInUse: - 'kubernetes.io/rbd/[]:' - kubernetes.io/rbd/[xxxxxxx:6789 xxxxxxxxx:6789]:volume-9a106847-4def-4d1e-9603-4c7099b22a31 after fix: volumesAttached: - devicePath: "" name: kubernetes.io/rbd/volumes:volume-9a106847-4def-4d1e-9603-4c7099b22a31 volumesInUse: - kubernetes.io/rbd/volumes:volume-9a106847-4def-4d1e-9603-4c7099b22a31
parents 8f8579d4 e6e3b756
...@@ -81,7 +81,7 @@ func (plugin *rbdPlugin) GetPluginName() string { ...@@ -81,7 +81,7 @@ func (plugin *rbdPlugin) GetPluginName() string {
} }
func (plugin *rbdPlugin) GetVolumeName(spec *volume.Spec) (string, error) { func (plugin *rbdPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
mon, err := getVolumeSourceMonitors(spec) pool, err := getVolumeSourcePool(spec)
if err != nil { if err != nil {
return "", err return "", err
} }
...@@ -92,7 +92,7 @@ func (plugin *rbdPlugin) GetVolumeName(spec *volume.Spec) (string, error) { ...@@ -92,7 +92,7 @@ func (plugin *rbdPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
return fmt.Sprintf( return fmt.Sprintf(
"%v:%v", "%v:%v",
mon, pool,
img), nil img), nil
} }
...@@ -346,11 +346,22 @@ func (plugin *rbdPlugin) newUnmounterInternal(volName string, podUID types.UID, ...@@ -346,11 +346,22 @@ func (plugin *rbdPlugin) newUnmounterInternal(volName string, podUID types.UID,
} }
func (plugin *rbdPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) { func (plugin *rbdPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
mounter := plugin.host.GetMounter(plugin.GetPluginName())
pluginDir := plugin.host.GetPluginDir(plugin.GetPluginName())
sourceName, err := mounter.GetDeviceNameFromMount(mountPath, pluginDir)
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)
}
rbdVolume := &v1.Volume{ rbdVolume := &v1.Volume{
Name: volumeName, Name: volumeName,
VolumeSource: v1.VolumeSource{ VolumeSource: v1.VolumeSource{
RBD: &v1.RBDVolumeSource{ RBD: &v1.RBDVolumeSource{
CephMonitors: []string{}, RBDPool: s[0],
RBDImage: s[1],
}, },
}, },
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment