From 541edb744811ee0cef82188ba7887e872f8bbc72 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Tue, 22 May 2018 06:26:56 +0000 Subject: [PATCH] add volumeName in getVolumeSpecFromGlobalMapPath fix test build failure --- pkg/volume/azure_dd/azure_dd_block.go | 8 ++++++-- pkg/volume/azure_dd/azure_dd_block_test.go | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/volume/azure_dd/azure_dd_block.go b/pkg/volume/azure_dd/azure_dd_block.go index 6a02e786235..9ded780ef46 100644 --- a/pkg/volume/azure_dd/azure_dd_block.go +++ b/pkg/volume/azure_dd/azure_dd_block.go @@ -22,6 +22,7 @@ import ( "github.com/golang/glog" "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/kubernetes/pkg/util/mount" kstrings "k8s.io/kubernetes/pkg/util/strings" @@ -49,10 +50,10 @@ func (plugin *azureDataDiskPlugin) ConstructBlockVolumeSpec(podUID types.UID, vo return nil, fmt.Errorf("failed to get volume plugin information from globalMapPathUUID: %v", globalMapPathUUID) } - return getVolumeSpecFromGlobalMapPath(globalMapPath) + return getVolumeSpecFromGlobalMapPath(globalMapPath, volumeName) } -func getVolumeSpecFromGlobalMapPath(globalMapPath string) (*volume.Spec, error) { +func getVolumeSpecFromGlobalMapPath(globalMapPath, volumeName string) (*volume.Spec, error) { // Get volume spec information from globalMapPath // globalMapPath example: // plugins/kubernetes.io/{PluginName}/{DefaultKubeletVolumeDevicesDirName}/{volumeID} @@ -64,6 +65,9 @@ func getVolumeSpecFromGlobalMapPath(globalMapPath string) (*volume.Spec, error) glog.V(5).Infof("got diskName(%s) from globalMapPath: %s", globalMapPath, diskName) block := v1.PersistentVolumeBlock pv := &v1.PersistentVolume{ + ObjectMeta: metav1.ObjectMeta{ + Name: volumeName, + }, Spec: v1.PersistentVolumeSpec{ PersistentVolumeSource: v1.PersistentVolumeSource{ AzureDisk: &v1.AzureDiskVolumeSource{ diff --git a/pkg/volume/azure_dd/azure_dd_block_test.go b/pkg/volume/azure_dd/azure_dd_block_test.go index 127870f707d..1951707470d 100644 --- a/pkg/volume/azure_dd/azure_dd_block_test.go +++ b/pkg/volume/azure_dd/azure_dd_block_test.go @@ -50,13 +50,13 @@ func TestGetVolumeSpecFromGlobalMapPath(t *testing.T) { expectedGlobalPath := filepath.Join(tmpVDir, testGlobalPath) //Bad Path - badspec, err := getVolumeSpecFromGlobalMapPath("") + badspec, err := getVolumeSpecFromGlobalMapPath("", "") if badspec != nil || err == nil { t.Errorf("Expected not to get spec from GlobalMapPath but did") } // Good Path - spec, err := getVolumeSpecFromGlobalMapPath(expectedGlobalPath) + spec, err := getVolumeSpecFromGlobalMapPath(expectedGlobalPath, "") if spec == nil || err != nil { t.Fatalf("Failed to get spec from GlobalMapPath: %v", err) }