mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-01 09:18:45 +00:00
add volumeName in getVolumeSpecFromGlobalMapPath
fix test build failure
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
|||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/kubernetes/pkg/util/mount"
|
"k8s.io/kubernetes/pkg/util/mount"
|
||||||
kstrings "k8s.io/kubernetes/pkg/util/strings"
|
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 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
|
// Get volume spec information from globalMapPath
|
||||||
// globalMapPath example:
|
// globalMapPath example:
|
||||||
// plugins/kubernetes.io/{PluginName}/{DefaultKubeletVolumeDevicesDirName}/{volumeID}
|
// 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)
|
glog.V(5).Infof("got diskName(%s) from globalMapPath: %s", globalMapPath, diskName)
|
||||||
block := v1.PersistentVolumeBlock
|
block := v1.PersistentVolumeBlock
|
||||||
pv := &v1.PersistentVolume{
|
pv := &v1.PersistentVolume{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: volumeName,
|
||||||
|
},
|
||||||
Spec: v1.PersistentVolumeSpec{
|
Spec: v1.PersistentVolumeSpec{
|
||||||
PersistentVolumeSource: v1.PersistentVolumeSource{
|
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||||
AzureDisk: &v1.AzureDiskVolumeSource{
|
AzureDisk: &v1.AzureDiskVolumeSource{
|
||||||
|
@@ -50,13 +50,13 @@ func TestGetVolumeSpecFromGlobalMapPath(t *testing.T) {
|
|||||||
expectedGlobalPath := filepath.Join(tmpVDir, testGlobalPath)
|
expectedGlobalPath := filepath.Join(tmpVDir, testGlobalPath)
|
||||||
|
|
||||||
//Bad Path
|
//Bad Path
|
||||||
badspec, err := getVolumeSpecFromGlobalMapPath("")
|
badspec, err := getVolumeSpecFromGlobalMapPath("", "")
|
||||||
if badspec != nil || err == nil {
|
if badspec != nil || err == nil {
|
||||||
t.Errorf("Expected not to get spec from GlobalMapPath but did")
|
t.Errorf("Expected not to get spec from GlobalMapPath but did")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Good Path
|
// Good Path
|
||||||
spec, err := getVolumeSpecFromGlobalMapPath(expectedGlobalPath)
|
spec, err := getVolumeSpecFromGlobalMapPath(expectedGlobalPath, "")
|
||||||
if spec == nil || err != nil {
|
if spec == nil || err != nil {
|
||||||
t.Fatalf("Failed to get spec from GlobalMapPath: %v", err)
|
t.Fatalf("Failed to get spec from GlobalMapPath: %v", err)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user