mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Merge pull request #83451 from jsafrane/block-reconstruct
Fix block volume reconstruction
This commit is contained in:
commit
8098bae921
@ -24,6 +24,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
@ -518,7 +519,8 @@ func (rc *reconciler) reconstructVolume(volume podVolume) (*reconstructedVolume,
|
|||||||
pod.UID,
|
pod.UID,
|
||||||
newMapperErr)
|
newMapperErr)
|
||||||
}
|
}
|
||||||
checkPath, _ = volumeMapper.GetPodDeviceMapPath()
|
mapDir, linkName := volumeMapper.GetPodDeviceMapPath()
|
||||||
|
checkPath = filepath.Join(mapDir, linkName)
|
||||||
} else {
|
} else {
|
||||||
var err error
|
var err error
|
||||||
volumeMounter, err = plugin.NewMounter(
|
volumeMounter, err = plugin.NewMounter(
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
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/klog"
|
"k8s.io/klog"
|
||||||
"k8s.io/kubernetes/pkg/util/mount"
|
"k8s.io/kubernetes/pkg/util/mount"
|
||||||
@ -51,10 +52,10 @@ func (plugin *awsElasticBlockStorePlugin) ConstructBlockVolumeSpec(podUID types.
|
|||||||
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(volumeName, globalMapPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVolumeSpecFromGlobalMapPath(globalMapPath string) (*volume.Spec, error) {
|
func getVolumeSpecFromGlobalMapPath(volumeName string, globalMapPath 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}
|
||||||
@ -68,6 +69,9 @@ func getVolumeSpecFromGlobalMapPath(globalMapPath string) (*volume.Spec, error)
|
|||||||
}
|
}
|
||||||
block := v1.PersistentVolumeBlock
|
block := v1.PersistentVolumeBlock
|
||||||
awsVolume := &v1.PersistentVolume{
|
awsVolume := &v1.PersistentVolume{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: volumeName,
|
||||||
|
},
|
||||||
Spec: v1.PersistentVolumeSpec{
|
Spec: v1.PersistentVolumeSpec{
|
||||||
PersistentVolumeSource: v1.PersistentVolumeSource{
|
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||||
AWSElasticBlockStore: &v1.AWSElasticBlockStoreVolumeSource{
|
AWSElasticBlockStore: &v1.AWSElasticBlockStoreVolumeSource{
|
||||||
|
@ -52,16 +52,19 @@ 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.Fatalf("Expected not to get spec from GlobalMapPath but did")
|
t.Fatalf("Expected not to get spec from GlobalMapPath but did")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Good Path
|
// Good Path
|
||||||
spec, err := getVolumeSpecFromGlobalMapPath(expectedGlobalPath)
|
spec, err := getVolumeSpecFromGlobalMapPath("myVolume", 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)
|
||||||
}
|
}
|
||||||
|
if spec.PersistentVolume.Name != "myVolume" {
|
||||||
|
t.Errorf("Invalid PV name from GlobalMapPath spec: %s", spec.PersistentVolume.Name)
|
||||||
|
}
|
||||||
if spec.PersistentVolume.Spec.AWSElasticBlockStore.VolumeID != testVolName {
|
if spec.PersistentVolume.Spec.AWSElasticBlockStore.VolumeID != testVolName {
|
||||||
t.Errorf("Invalid volumeID from GlobalMapPath spec: %s", spec.PersistentVolume.Spec.AWSElasticBlockStore.VolumeID)
|
t.Errorf("Invalid volumeID from GlobalMapPath spec: %s", spec.PersistentVolume.Spec.AWSElasticBlockStore.VolumeID)
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
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/klog"
|
"k8s.io/klog"
|
||||||
"k8s.io/kubernetes/pkg/util/mount"
|
"k8s.io/kubernetes/pkg/util/mount"
|
||||||
@ -53,10 +54,10 @@ func (plugin *cinderPlugin) ConstructBlockVolumeSpec(podUID types.UID, volumeNam
|
|||||||
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(volumeName, globalMapPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVolumeSpecFromGlobalMapPath(globalMapPath string) (*volume.Spec, error) {
|
func getVolumeSpecFromGlobalMapPath(volumeName, globalMapPath 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}
|
||||||
@ -67,6 +68,9 @@ func getVolumeSpecFromGlobalMapPath(globalMapPath string) (*volume.Spec, error)
|
|||||||
}
|
}
|
||||||
block := v1.PersistentVolumeBlock
|
block := v1.PersistentVolumeBlock
|
||||||
cinderVolume := &v1.PersistentVolume{
|
cinderVolume := &v1.PersistentVolume{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: volumeName,
|
||||||
|
},
|
||||||
Spec: v1.PersistentVolumeSpec{
|
Spec: v1.PersistentVolumeSpec{
|
||||||
PersistentVolumeSource: v1.PersistentVolumeSource{
|
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||||
Cinder: &v1.CinderPersistentVolumeSource{
|
Cinder: &v1.CinderPersistentVolumeSource{
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
utiltesting "k8s.io/client-go/util/testing"
|
utiltesting "k8s.io/client-go/util/testing"
|
||||||
@ -52,16 +52,19 @@ 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("myVolume", 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)
|
||||||
}
|
}
|
||||||
|
if spec.PersistentVolume.Name != "myVolume" {
|
||||||
|
t.Errorf("Invalid PV name from GlobalMapPath spec: %s", spec.PersistentVolume.Name)
|
||||||
|
}
|
||||||
if spec.PersistentVolume.Spec.Cinder.VolumeID != testVolName {
|
if spec.PersistentVolume.Spec.Cinder.VolumeID != testVolName {
|
||||||
t.Errorf("Invalid volumeID from GlobalMapPath spec: %s", spec.PersistentVolume.Spec.Cinder.VolumeID)
|
t.Errorf("Invalid volumeID from GlobalMapPath spec: %s", spec.PersistentVolume.Spec.Cinder.VolumeID)
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
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/klog"
|
"k8s.io/klog"
|
||||||
"k8s.io/kubernetes/pkg/util/mount"
|
"k8s.io/kubernetes/pkg/util/mount"
|
||||||
@ -54,10 +55,10 @@ func (plugin *gcePersistentDiskPlugin) ConstructBlockVolumeSpec(podUID types.UID
|
|||||||
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(volumeName, globalMapPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVolumeSpecFromGlobalMapPath(globalMapPath string) (*volume.Spec, error) {
|
func getVolumeSpecFromGlobalMapPath(volumeName, globalMapPath 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}
|
||||||
@ -68,6 +69,9 @@ func getVolumeSpecFromGlobalMapPath(globalMapPath string) (*volume.Spec, error)
|
|||||||
}
|
}
|
||||||
block := v1.PersistentVolumeBlock
|
block := v1.PersistentVolumeBlock
|
||||||
gceVolume := &v1.PersistentVolume{
|
gceVolume := &v1.PersistentVolume{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: volumeName,
|
||||||
|
},
|
||||||
Spec: v1.PersistentVolumeSpec{
|
Spec: v1.PersistentVolumeSpec{
|
||||||
PersistentVolumeSource: v1.PersistentVolumeSource{
|
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||||
GCEPersistentDisk: &v1.GCEPersistentDiskVolumeSource{
|
GCEPersistentDisk: &v1.GCEPersistentDiskVolumeSource{
|
||||||
|
@ -52,16 +52,19 @@ 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("myVolume", 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)
|
||||||
}
|
}
|
||||||
|
if spec.PersistentVolume.Name != "myVolume" {
|
||||||
|
t.Errorf("Invalid PV name from GlobalMapPath spec: %s", spec.PersistentVolume.Name)
|
||||||
|
}
|
||||||
if spec.PersistentVolume.Spec.GCEPersistentDisk.PDName != testPdName {
|
if spec.PersistentVolume.Spec.GCEPersistentDisk.PDName != testPdName {
|
||||||
t.Errorf("Invalid pdName from GlobalMapPath spec: %s", spec.PersistentVolume.Spec.GCEPersistentDisk.PDName)
|
t.Errorf("Invalid pdName from GlobalMapPath spec: %s", spec.PersistentVolume.Spec.GCEPersistentDisk.PDName)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,8 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
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/klog"
|
"k8s.io/klog"
|
||||||
"k8s.io/kubernetes/pkg/util/mount"
|
"k8s.io/kubernetes/pkg/util/mount"
|
||||||
@ -49,10 +50,10 @@ func (plugin *vsphereVolumePlugin) ConstructBlockVolumeSpec(podUID types.UID, vo
|
|||||||
if len(globalMapPath) <= 1 {
|
if len(globalMapPath) <= 1 {
|
||||||
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(volumeName, globalMapPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVolumeSpecFromGlobalMapPath(globalMapPath string) (*volume.Spec, error) {
|
func getVolumeSpecFromGlobalMapPath(volumeName, globalMapPath string) (*volume.Spec, error) {
|
||||||
// Construct volume spec from globalMapPath
|
// Construct volume spec 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)
|
|||||||
}
|
}
|
||||||
block := v1.PersistentVolumeBlock
|
block := v1.PersistentVolumeBlock
|
||||||
vsphereVolume := &v1.PersistentVolume{
|
vsphereVolume := &v1.PersistentVolume{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: volumeName,
|
||||||
|
},
|
||||||
Spec: v1.PersistentVolumeSpec{
|
Spec: v1.PersistentVolumeSpec{
|
||||||
PersistentVolumeSource: v1.PersistentVolumeSource{
|
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||||
VsphereVolume: &v1.VsphereVirtualDiskVolumeSource{
|
VsphereVolume: &v1.VsphereVirtualDiskVolumeSource{
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
utiltesting "k8s.io/client-go/util/testing"
|
utiltesting "k8s.io/client-go/util/testing"
|
||||||
@ -51,16 +51,19 @@ 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("myVolume", expectedGlobalPath)
|
||||||
if spec == nil || err != nil {
|
if spec == nil || err != nil {
|
||||||
t.Fatalf("Failed to get spec from GlobalMapPath: %s", err)
|
t.Fatalf("Failed to get spec from GlobalMapPath: %s", err)
|
||||||
}
|
}
|
||||||
|
if spec.PersistentVolume.Name != "myVolume" {
|
||||||
|
t.Errorf("Invalid PV name from GlobalMapPath spec: %s", spec.PersistentVolume.Name)
|
||||||
|
}
|
||||||
if spec.PersistentVolume.Spec.VsphereVolume.VolumePath != testVolumePath {
|
if spec.PersistentVolume.Spec.VsphereVolume.VolumePath != testVolumePath {
|
||||||
t.Fatalf("Invalid volumePath from GlobalMapPath spec: %s", spec.PersistentVolume.Spec.VsphereVolume.VolumePath)
|
t.Fatalf("Invalid volumePath from GlobalMapPath spec: %s", spec.PersistentVolume.Spec.VsphereVolume.VolumePath)
|
||||||
}
|
}
|
||||||
|
@ -140,8 +140,9 @@ func (s *disruptiveTestSuite) defineTests(driver TestDriver, pattern testpattern
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range disruptiveTestTable {
|
for _, test := range disruptiveTestTable {
|
||||||
if test.runTestFile != nil {
|
func(t disruptiveTest) {
|
||||||
func(t disruptiveTest) {
|
if (pattern.VolMode == v1.PersistentVolumeBlock && t.runTestBlock != nil) ||
|
||||||
|
(pattern.VolMode == v1.PersistentVolumeFilesystem && t.runTestFile != nil) {
|
||||||
ginkgo.It(t.testItStmt, func() {
|
ginkgo.It(t.testItStmt, func() {
|
||||||
init()
|
init()
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
@ -158,13 +159,14 @@ func (s *disruptiveTestSuite) defineTests(driver TestDriver, pattern testpattern
|
|||||||
l.pod, err = e2epod.CreateSecPodWithNodeSelection(l.cs, l.ns.Name, pvcs, inlineSources, false, "", false, false, e2epv.SELinuxLabel, nil, e2epod.NodeSelection{Name: l.config.ClientNodeName}, framework.PodStartTimeout)
|
l.pod, err = e2epod.CreateSecPodWithNodeSelection(l.cs, l.ns.Name, pvcs, inlineSources, false, "", false, false, e2epv.SELinuxLabel, nil, e2epod.NodeSelection{Name: l.config.ClientNodeName}, framework.PodStartTimeout)
|
||||||
framework.ExpectNoError(err, "While creating pods for kubelet restart test")
|
framework.ExpectNoError(err, "While creating pods for kubelet restart test")
|
||||||
|
|
||||||
if pattern.VolMode == v1.PersistentVolumeBlock {
|
if pattern.VolMode == v1.PersistentVolumeBlock && t.runTestBlock != nil {
|
||||||
t.runTestBlock(l.cs, l.config.Framework, l.pod)
|
t.runTestBlock(l.cs, l.config.Framework, l.pod)
|
||||||
} else {
|
}
|
||||||
|
if pattern.VolMode == v1.PersistentVolumeFilesystem && t.runTestFile != nil {
|
||||||
t.runTestFile(l.cs, l.config.Framework, l.pod)
|
t.runTestFile(l.cs, l.config.Framework, l.pod)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}(test)
|
}
|
||||||
}
|
}(test)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,18 +318,28 @@ func TestVolumeUnmapsFromDeletedPodWithForceOption(c clientset.Interface, f *fra
|
|||||||
nodeIP = nodeIP + ":22"
|
nodeIP = nodeIP + ":22"
|
||||||
|
|
||||||
// Creating command to check whether path exists
|
// Creating command to check whether path exists
|
||||||
command := fmt.Sprintf("ls /var/lib/kubelet/pods/%s/volumeDevices/*/ | grep '.'", clientPod.UID)
|
podDirectoryCmd := fmt.Sprintf("ls /var/lib/kubelet/pods/%s/volumeDevices/*/ | grep '.'", clientPod.UID)
|
||||||
if isSudoPresent(nodeIP, framework.TestContext.Provider) {
|
if isSudoPresent(nodeIP, framework.TestContext.Provider) {
|
||||||
command = fmt.Sprintf("sudo sh -c \"%s\"", command)
|
podDirectoryCmd = fmt.Sprintf("sudo sh -c \"%s\"", podDirectoryCmd)
|
||||||
|
}
|
||||||
|
// Directories in the global directory have unpredictable names, however, device symlinks
|
||||||
|
// have the same name as pod.UID. So just find anything with pod.UID name.
|
||||||
|
globalBlockDirectoryCmd := fmt.Sprintf("find /var/lib/kubelet/plugins -name %s", clientPod.UID)
|
||||||
|
if isSudoPresent(nodeIP, framework.TestContext.Provider) {
|
||||||
|
globalBlockDirectoryCmd = fmt.Sprintf("sudo sh -c \"%s\"", globalBlockDirectoryCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("Expecting the symlinks from PodDeviceMapPath to be found.")
|
ginkgo.By("Expecting the symlinks from PodDeviceMapPath to be found.")
|
||||||
result, err := e2essh.SSH(command, nodeIP, framework.TestContext.Provider)
|
result, err := e2essh.SSH(podDirectoryCmd, nodeIP, framework.TestContext.Provider)
|
||||||
e2essh.LogResult(result)
|
e2essh.LogResult(result)
|
||||||
framework.ExpectNoError(err, "Encountered SSH error.")
|
framework.ExpectNoError(err, "Encountered SSH error.")
|
||||||
framework.ExpectEqual(result.Code, 0, fmt.Sprintf("Expected grep exit code of 0, got %d", result.Code))
|
framework.ExpectEqual(result.Code, 0, fmt.Sprintf("Expected grep exit code of 0, got %d", result.Code))
|
||||||
|
|
||||||
// TODO: Needs to check GetGlobalMapPath and descriptor lock, as well.
|
ginkgo.By("Expecting the symlinks from global map path to be found.")
|
||||||
|
result, err = e2essh.SSH(globalBlockDirectoryCmd, nodeIP, framework.TestContext.Provider)
|
||||||
|
e2essh.LogResult(result)
|
||||||
|
framework.ExpectNoError(err, "Encountered SSH error.")
|
||||||
|
framework.ExpectEqual(result.Code, 0, fmt.Sprintf("Expected find exit code of 0, got %d", result.Code))
|
||||||
|
|
||||||
// This command is to make sure kubelet is started after test finishes no matter it fails or not.
|
// This command is to make sure kubelet is started after test finishes no matter it fails or not.
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -358,12 +368,16 @@ func TestVolumeUnmapsFromDeletedPodWithForceOption(c clientset.Interface, f *fra
|
|||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("Expecting the symlink from PodDeviceMapPath not to be found.")
|
ginkgo.By("Expecting the symlink from PodDeviceMapPath not to be found.")
|
||||||
result, err = e2essh.SSH(command, nodeIP, framework.TestContext.Provider)
|
result, err = e2essh.SSH(podDirectoryCmd, nodeIP, framework.TestContext.Provider)
|
||||||
e2essh.LogResult(result)
|
e2essh.LogResult(result)
|
||||||
framework.ExpectNoError(err, "Encountered SSH error.")
|
framework.ExpectNoError(err, "Encountered SSH error.")
|
||||||
gomega.Expect(result.Stdout).To(gomega.BeEmpty(), "Expected grep stdout to be empty.")
|
gomega.Expect(result.Stdout).To(gomega.BeEmpty(), "Expected grep stdout to be empty.")
|
||||||
|
|
||||||
// TODO: Needs to check GetGlobalMapPath and descriptor lock, as well.
|
ginkgo.By("Expecting the symlinks from global map path not to be found.")
|
||||||
|
result, err = e2essh.SSH(globalBlockDirectoryCmd, nodeIP, framework.TestContext.Provider)
|
||||||
|
e2essh.LogResult(result)
|
||||||
|
framework.ExpectNoError(err, "Encountered SSH error.")
|
||||||
|
gomega.Expect(result.Stdout).To(gomega.BeEmpty(), "Expected find stdout to be empty.")
|
||||||
|
|
||||||
framework.Logf("Volume unmaped on node %s", clientPod.Spec.NodeName)
|
framework.Logf("Volume unmaped on node %s", clientPod.Spec.NodeName)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user