mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
fix rbd volume plugin ConstructVolume
This commit is contained in:
parent
7b0e6b7f14
commit
e6e3b756c6
@ -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) {
|
|||||||
|
|
||||||
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,
|
|||||||
}
|
}
|
||||||
|
|
||||||
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],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user