From c240042231a3bec3907aae8e9f50ef68be545995 Mon Sep 17 00:00:00 2001 From: Miao Luo Date: Sat, 19 Nov 2016 14:02:35 -0800 Subject: [PATCH] Fix photon controller plugin to construct with correct PdID The input variable of function ConstructVolumeSpec is the volume spec name instead of persistent disk ID. Previously the function directly construct new volume spec by assigning volume spec name to persistent disk ID, which will result in mismatching of mount path. The fix will find the pdID according to mount path and construct volume spec with the correct pdID. --- pkg/volume/photon_pd/photon_pd.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/volume/photon_pd/photon_pd.go b/pkg/volume/photon_pd/photon_pd.go index e15749fbaf9..a8c0d2541ae 100644 --- a/pkg/volume/photon_pd/photon_pd.go +++ b/pkg/volume/photon_pd/photon_pd.go @@ -119,12 +119,19 @@ func (plugin *photonPersistentDiskPlugin) newUnmounterInternal(volName string, p }}, nil } -func (plugin *photonPersistentDiskPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) { +func (plugin *photonPersistentDiskPlugin) ConstructVolumeSpec(volumeSpecName, mountPath string) (*volume.Spec, error) { + mounter := plugin.host.GetMounter() + pluginDir := plugin.host.GetPluginDir(plugin.GetPluginName()) + pdID, err := mounter.GetDeviceNameFromMount(mountPath, pluginDir) + if err != nil { + return nil, err + } + photonPersistentDisk := &v1.Volume{ - Name: volumeName, + Name: volumeSpecName, VolumeSource: v1.VolumeSource{ PhotonPersistentDisk: &v1.PhotonPersistentDiskVolumeSource{ - PdID: volumeName, + PdID: pdID, }, }, }