123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602 |
- /*
- Copyright 2018 The Kubernetes Authors.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
- package csi
- import (
- "context"
- "errors"
- "fmt"
- "os"
- "path/filepath"
- "testing"
- api "k8s.io/api/core/v1"
- "k8s.io/api/storage/v1beta1"
- meta "k8s.io/apimachinery/pkg/apis/meta/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- utilfeature "k8s.io/apiserver/pkg/util/feature"
- fakeclient "k8s.io/client-go/kubernetes/fake"
- featuregatetesting "k8s.io/component-base/featuregate/testing"
- "k8s.io/kubernetes/pkg/features"
- "k8s.io/kubernetes/pkg/volume"
- )
- func prepareBlockMapperTest(plug *csiPlugin, specVolumeName string, t *testing.T) (*csiBlockMapper, *volume.Spec, *api.PersistentVolume, error) {
- registerFakePlugin(testDriver, "endpoint", []string{"1.0.0"}, t)
- pv := makeTestPV(specVolumeName, 10, testDriver, testVol)
- spec := volume.NewSpecFromPersistentVolume(pv, pv.Spec.PersistentVolumeSource.CSI.ReadOnly)
- mapper, err := plug.NewBlockVolumeMapper(
- spec,
- &api.Pod{ObjectMeta: meta.ObjectMeta{UID: testPodUID, Namespace: testns}},
- volume.VolumeOptions{},
- )
- if err != nil {
- return nil, nil, nil, fmt.Errorf("Failed to make a new Mapper: %v", err)
- }
- csiMapper := mapper.(*csiBlockMapper)
- return csiMapper, spec, pv, nil
- }
- func prepareBlockUnmapperTest(plug *csiPlugin, specVolumeName string, t *testing.T) (*csiBlockMapper, *volume.Spec, *api.PersistentVolume, error) {
- registerFakePlugin(testDriver, "endpoint", []string{"1.0.0"}, t)
- pv := makeTestPV(specVolumeName, 10, testDriver, testVol)
- spec := volume.NewSpecFromPersistentVolume(pv, pv.Spec.PersistentVolumeSource.CSI.ReadOnly)
- // save volume data
- dir := getVolumeDeviceDataDir(pv.ObjectMeta.Name, plug.host)
- if err := os.MkdirAll(dir, 0755); err != nil && !os.IsNotExist(err) {
- t.Errorf("failed to create dir [%s]: %v", dir, err)
- }
- if err := saveVolumeData(
- dir,
- volDataFileName,
- map[string]string{
- volDataKey.specVolID: pv.ObjectMeta.Name,
- volDataKey.driverName: testDriver,
- volDataKey.volHandle: testVol,
- },
- ); err != nil {
- t.Fatalf("failed to save volume data: %v", err)
- }
- unmapper, err := plug.NewBlockVolumeUnmapper(pv.ObjectMeta.Name, testPodUID)
- if err != nil {
- t.Fatalf("failed to make a new Unmapper: %v", err)
- }
- csiUnmapper := unmapper.(*csiBlockMapper)
- csiUnmapper.csiClient = setupClient(t, true)
- return csiUnmapper, spec, pv, nil
- }
- func TestBlockMapperGetGlobalMapPath(t *testing.T) {
- defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIBlockVolume, true)()
- plug, tmpDir := newTestPlugin(t, nil)
- defer os.RemoveAll(tmpDir)
- // TODO (vladimirvivien) specName with slashes will not work
- testCases := []struct {
- name string
- specVolumeName string
- path string
- }{
- {
- name: "simple specName",
- specVolumeName: "spec-0",
- path: filepath.Join(tmpDir, fmt.Sprintf("plugins/kubernetes.io/csi/volumeDevices/%s/%s", "spec-0", "dev")),
- },
- {
- name: "specName with dots",
- specVolumeName: "test.spec.1",
- path: filepath.Join(tmpDir, fmt.Sprintf("plugins/kubernetes.io/csi/volumeDevices/%s/%s", "test.spec.1", "dev")),
- },
- }
- for _, tc := range testCases {
- t.Logf("test case: %s", tc.name)
- csiMapper, spec, _, err := prepareBlockMapperTest(plug, tc.specVolumeName, t)
- if err != nil {
- t.Fatalf("Failed to make a new Mapper: %v", err)
- }
- path, err := csiMapper.GetGlobalMapPath(spec)
- if err != nil {
- t.Errorf("mapper GetGlobalMapPath failed: %v", err)
- }
- if tc.path != path {
- t.Errorf("expecting path %s, got %s", tc.path, path)
- }
- }
- }
- func TestBlockMapperGetStagingPath(t *testing.T) {
- defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIBlockVolume, true)()
- plug, tmpDir := newTestPlugin(t, nil)
- defer os.RemoveAll(tmpDir)
- testCases := []struct {
- name string
- specVolumeName string
- path string
- }{
- {
- name: "simple specName",
- specVolumeName: "spec-0",
- path: filepath.Join(tmpDir, fmt.Sprintf("plugins/kubernetes.io/csi/volumeDevices/staging/%s", "spec-0")),
- },
- {
- name: "specName with dots",
- specVolumeName: "test.spec.1",
- path: filepath.Join(tmpDir, fmt.Sprintf("plugins/kubernetes.io/csi/volumeDevices/staging/%s", "test.spec.1")),
- },
- }
- for _, tc := range testCases {
- t.Logf("test case: %s", tc.name)
- csiMapper, _, _, err := prepareBlockMapperTest(plug, tc.specVolumeName, t)
- if err != nil {
- t.Fatalf("Failed to make a new Mapper: %v", err)
- }
- path := csiMapper.getStagingPath()
- if tc.path != path {
- t.Errorf("expecting path %s, got %s", tc.path, path)
- }
- }
- }
- func TestBlockMapperGetPublishPath(t *testing.T) {
- defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIBlockVolume, true)()
- plug, tmpDir := newTestPlugin(t, nil)
- defer os.RemoveAll(tmpDir)
- testCases := []struct {
- name string
- specVolumeName string
- path string
- }{
- {
- name: "simple specName",
- specVolumeName: "spec-0",
- path: filepath.Join(tmpDir, fmt.Sprintf("plugins/kubernetes.io/csi/volumeDevices/publish/%s/%s", "spec-0", testPodUID)),
- },
- {
- name: "specName with dots",
- specVolumeName: "test.spec.1",
- path: filepath.Join(tmpDir, fmt.Sprintf("plugins/kubernetes.io/csi/volumeDevices/publish/%s/%s", "test.spec.1", testPodUID)),
- },
- }
- for _, tc := range testCases {
- t.Logf("test case: %s", tc.name)
- csiMapper, _, _, err := prepareBlockMapperTest(plug, tc.specVolumeName, t)
- if err != nil {
- t.Fatalf("Failed to make a new Mapper: %v", err)
- }
- path := csiMapper.getPublishPath()
- if tc.path != path {
- t.Errorf("expecting path %s, got %s", tc.path, path)
- }
- }
- }
- func TestBlockMapperGetDeviceMapPath(t *testing.T) {
- defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIBlockVolume, true)()
- plug, tmpDir := newTestPlugin(t, nil)
- defer os.RemoveAll(tmpDir)
- testCases := []struct {
- name string
- specVolumeName string
- path string
- }{
- {
- name: "simple specName",
- specVolumeName: "spec-0",
- path: filepath.Join(tmpDir, fmt.Sprintf("pods/%s/volumeDevices/kubernetes.io~csi", testPodUID)),
- },
- {
- name: "specName with dots",
- specVolumeName: "test.spec.1",
- path: filepath.Join(tmpDir, fmt.Sprintf("pods/%s/volumeDevices/kubernetes.io~csi", testPodUID)),
- },
- }
- for _, tc := range testCases {
- t.Logf("test case: %s", tc.name)
- csiMapper, _, _, err := prepareBlockMapperTest(plug, tc.specVolumeName, t)
- if err != nil {
- t.Fatalf("Failed to make a new Mapper: %v", err)
- }
- path, volName := csiMapper.GetPodDeviceMapPath()
- if tc.path != path {
- t.Errorf("expecting path %s, got %s", tc.path, path)
- }
- if tc.specVolumeName != volName {
- t.Errorf("expecting volName %s, got %s", tc.specVolumeName, volName)
- }
- }
- }
- func TestBlockMapperSetupDevice(t *testing.T) {
- defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIBlockVolume, true)()
- plug, tmpDir := newTestPlugin(t, nil)
- defer os.RemoveAll(tmpDir)
- csiMapper, _, pv, err := prepareBlockMapperTest(plug, "test-pv", t)
- if err != nil {
- t.Fatalf("Failed to make a new Mapper: %v", err)
- }
- pvName := pv.GetName()
- nodeName := string(plug.host.GetNodeName())
- csiMapper.csiClient = setupClient(t, true)
- attachID := getAttachmentName(csiMapper.volumeID, string(csiMapper.driverName), string(nodeName))
- attachment := makeTestAttachment(attachID, nodeName, pvName)
- attachment.Status.Attached = true
- _, err = csiMapper.k8s.StorageV1().VolumeAttachments().Create(context.TODO(), attachment, metav1.CreateOptions{})
- if err != nil {
- t.Fatalf("failed to setup VolumeAttachment: %v", err)
- }
- t.Log("created attachement ", attachID)
- err = csiMapper.SetUpDevice()
- if err != nil {
- t.Fatalf("mapper failed to SetupDevice: %v", err)
- }
- // Check if NodeStageVolume staged to the right path
- stagingPath := csiMapper.getStagingPath()
- svols := csiMapper.csiClient.(*fakeCsiDriverClient).nodeClient.GetNodeStagedVolumes()
- svol, ok := svols[csiMapper.volumeID]
- if !ok {
- t.Error("csi server may not have received NodeStageVolume call")
- }
- if svol.Path != stagingPath {
- t.Errorf("csi server expected device path %s, got %s", stagingPath, svol.Path)
- }
- }
- func TestBlockMapperSetupDeviceError(t *testing.T) {
- defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIBlockVolume, true)()
- plug, tmpDir := newTestPlugin(t, nil)
- defer os.RemoveAll(tmpDir)
- csiMapper, _, pv, err := prepareBlockMapperTest(plug, "test-pv", t)
- if err != nil {
- t.Fatalf("Failed to make a new Mapper: %v", err)
- }
- pvName := pv.GetName()
- nodeName := string(plug.host.GetNodeName())
- csiMapper.csiClient = setupClient(t, true)
- fClient := csiMapper.csiClient.(*fakeCsiDriverClient)
- fClient.nodeClient.SetNextError(errors.New("mock final error"))
- attachID := getAttachmentName(csiMapper.volumeID, string(csiMapper.driverName), string(nodeName))
- attachment := makeTestAttachment(attachID, nodeName, pvName)
- attachment.Status.Attached = true
- _, err = csiMapper.k8s.StorageV1().VolumeAttachments().Create(context.Background(), attachment, metav1.CreateOptions{})
- if err != nil {
- t.Fatalf("failed to setup VolumeAttachment: %v", err)
- }
- t.Log("created attachement ", attachID)
- err = csiMapper.SetUpDevice()
- if err == nil {
- t.Fatal("mapper unexpectedly succeeded")
- }
- // Check that all directories have been cleaned
- // Check that all metadata / staging / publish directories were deleted
- dataDir := getVolumeDeviceDataDir(pv.ObjectMeta.Name, plug.host)
- if _, err := os.Stat(dataDir); err == nil {
- t.Errorf("volume publish data directory %s was not deleted", dataDir)
- }
- devDir := getVolumeDeviceDataDir(pv.ObjectMeta.Name, plug.host)
- if _, err := os.Stat(devDir); err == nil {
- t.Errorf("volume publish device directory %s was not deleted", devDir)
- }
- stagingPath := csiMapper.getStagingPath()
- if _, err := os.Stat(stagingPath); err == nil {
- t.Errorf("volume staging path %s was not deleted", stagingPath)
- }
- }
- func TestBlockMapperMapPodDevice(t *testing.T) {
- defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIBlockVolume, true)()
- plug, tmpDir := newTestPlugin(t, nil)
- defer os.RemoveAll(tmpDir)
- csiMapper, _, pv, err := prepareBlockMapperTest(plug, "test-pv", t)
- if err != nil {
- t.Fatalf("Failed to make a new Mapper: %v", err)
- }
- pvName := pv.GetName()
- nodeName := string(plug.host.GetNodeName())
- csiMapper.csiClient = setupClient(t, true)
- attachID := getAttachmentName(csiMapper.volumeID, string(csiMapper.driverName), nodeName)
- attachment := makeTestAttachment(attachID, nodeName, pvName)
- attachment.Status.Attached = true
- _, err = csiMapper.k8s.StorageV1().VolumeAttachments().Create(context.Background(), attachment, metav1.CreateOptions{})
- if err != nil {
- t.Fatalf("failed to setup VolumeAttachment: %v", err)
- }
- t.Log("created attachement ", attachID)
- // Map device to global and pod device map path
- path, err := csiMapper.MapPodDevice()
- if err != nil {
- t.Fatalf("mapper failed to GetGlobalMapPath: %v", err)
- }
- // Check if NodePublishVolume published to the right path
- pvols := csiMapper.csiClient.(*fakeCsiDriverClient).nodeClient.GetNodePublishedVolumes()
- pvol, ok := pvols[csiMapper.volumeID]
- if !ok {
- t.Error("csi server may not have received NodePublishVolume call")
- }
- publishPath := csiMapper.getPublishPath()
- if pvol.Path != publishPath {
- t.Errorf("csi server expected path %s, got %s", publishPath, pvol.Path)
- }
- if path != publishPath {
- t.Errorf("csi server expected path %s, but MapPodDevice returned %s", publishPath, path)
- }
- }
- func TestBlockMapperMapPodDeviceNotSupportAttach(t *testing.T) {
- defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIBlockVolume, true)()
- defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIDriverRegistry, true)()
- fakeClient := fakeclient.NewSimpleClientset()
- attachRequired := false
- fakeDriver := &v1beta1.CSIDriver{
- ObjectMeta: meta.ObjectMeta{
- Name: testDriver,
- },
- Spec: v1beta1.CSIDriverSpec{
- AttachRequired: &attachRequired,
- },
- }
- _, err := fakeClient.StorageV1beta1().CSIDrivers().Create(context.TODO(), fakeDriver, metav1.CreateOptions{})
- if err != nil {
- t.Fatalf("Failed to create a fakeDriver: %v", err)
- }
- // after the driver is created, create the plugin. newTestPlugin waits for the informer to sync,
- // such that csiMapper.SetUpDevice below sees the VolumeAttachment object in the lister.
- plug, tmpDir := newTestPlugin(t, fakeClient)
- defer os.RemoveAll(tmpDir)
- csiMapper, _, _, err := prepareBlockMapperTest(plug, "test-pv", t)
- if err != nil {
- t.Fatalf("Failed to make a new Mapper: %v", err)
- }
- csiMapper.csiClient = setupClient(t, true)
- // Map device to global and pod device map path
- path, err := csiMapper.MapPodDevice()
- if err != nil {
- t.Fatalf("mapper failed to GetGlobalMapPath: %v", err)
- }
- publishPath := csiMapper.getPublishPath()
- if path != publishPath {
- t.Errorf("path %s and %s doesn't match", path, publishPath)
- }
- }
- func TestBlockMapperTearDownDevice(t *testing.T) {
- defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIBlockVolume, true)()
- plug, tmpDir := newTestPlugin(t, nil)
- defer os.RemoveAll(tmpDir)
- _, spec, pv, err := prepareBlockMapperTest(plug, "test-pv", t)
- if err != nil {
- t.Fatalf("Failed to make a new Mapper: %v", err)
- }
- // save volume data
- dir := getVolumeDeviceDataDir(pv.ObjectMeta.Name, plug.host)
- if err := os.MkdirAll(dir, 0755); err != nil && !os.IsNotExist(err) {
- t.Errorf("failed to create dir [%s]: %v", dir, err)
- }
- if err := saveVolumeData(
- dir,
- volDataFileName,
- map[string]string{
- volDataKey.specVolID: pv.ObjectMeta.Name,
- volDataKey.driverName: testDriver,
- volDataKey.volHandle: testVol,
- },
- ); err != nil {
- t.Fatalf("failed to save volume data: %v", err)
- }
- unmapper, err := plug.NewBlockVolumeUnmapper(pv.ObjectMeta.Name, testPodUID)
- if err != nil {
- t.Fatalf("failed to make a new Unmapper: %v", err)
- }
- csiUnmapper := unmapper.(*csiBlockMapper)
- csiUnmapper.csiClient = setupClient(t, true)
- globalMapPath, err := csiUnmapper.GetGlobalMapPath(spec)
- if err != nil {
- t.Fatalf("unmapper failed to GetGlobalMapPath: %v", err)
- }
- err = csiUnmapper.TearDownDevice(globalMapPath, "/dev/test")
- if err != nil {
- t.Fatal(err)
- }
- // ensure csi client call and node unpblished
- pubs := csiUnmapper.csiClient.(*fakeCsiDriverClient).nodeClient.GetNodePublishedVolumes()
- if _, ok := pubs[csiUnmapper.volumeID]; ok {
- t.Error("csi server may not have received NodeUnpublishVolume call")
- }
- // ensure csi client call and node unstaged
- vols := csiUnmapper.csiClient.(*fakeCsiDriverClient).nodeClient.GetNodeStagedVolumes()
- if _, ok := vols[csiUnmapper.volumeID]; ok {
- t.Error("csi server may not have received NodeUnstageVolume call")
- }
- }
- func TestVolumeSetupTeardown(t *testing.T) {
- defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIBlockVolume, true)()
- // Follow volume setup + teardown sequences at top of cs_block.go and set up / clean up one CSI block device.
- // Focus on testing that there were no leftover files present after the cleanup.
- plug, tmpDir := newTestPlugin(t, nil)
- defer os.RemoveAll(tmpDir)
- csiMapper, spec, pv, err := prepareBlockMapperTest(plug, "test-pv", t)
- if err != nil {
- t.Fatalf("Failed to make a new Mapper: %v", err)
- }
- pvName := pv.GetName()
- nodeName := string(plug.host.GetNodeName())
- csiMapper.csiClient = setupClient(t, true)
- attachID := getAttachmentName(csiMapper.volumeID, string(csiMapper.driverName), string(nodeName))
- attachment := makeTestAttachment(attachID, nodeName, pvName)
- attachment.Status.Attached = true
- _, err = csiMapper.k8s.StorageV1().VolumeAttachments().Create(context.TODO(), attachment, metav1.CreateOptions{})
- if err != nil {
- t.Fatalf("failed to setup VolumeAttachment: %v", err)
- }
- t.Log("created attachement ", attachID)
- err = csiMapper.SetUpDevice()
- if err != nil {
- t.Fatalf("mapper failed to SetupDevice: %v", err)
- }
- // Check if NodeStageVolume staged to the right path
- stagingPath := csiMapper.getStagingPath()
- svols := csiMapper.csiClient.(*fakeCsiDriverClient).nodeClient.GetNodeStagedVolumes()
- svol, ok := svols[csiMapper.volumeID]
- if !ok {
- t.Error("csi server may not have received NodeStageVolume call")
- }
- if svol.Path != stagingPath {
- t.Errorf("csi server expected device path %s, got %s", stagingPath, svol.Path)
- }
- path, err := csiMapper.MapPodDevice()
- if err != nil {
- t.Fatalf("mapper failed to GetGlobalMapPath: %v", err)
- }
- pvols := csiMapper.csiClient.(*fakeCsiDriverClient).nodeClient.GetNodePublishedVolumes()
- pvol, ok := pvols[csiMapper.volumeID]
- if !ok {
- t.Error("csi server may not have received NodePublishVolume call")
- }
- publishPath := csiMapper.getPublishPath()
- if pvol.Path != publishPath {
- t.Errorf("csi server expected path %s, got %s", publishPath, pvol.Path)
- }
- if path != publishPath {
- t.Errorf("csi server expected path %s, but MapPodDevice returned %s", publishPath, path)
- }
- unmapper, err := plug.NewBlockVolumeUnmapper(pv.ObjectMeta.Name, testPodUID)
- if err != nil {
- t.Fatalf("failed to make a new Unmapper: %v", err)
- }
- csiUnmapper := unmapper.(*csiBlockMapper)
- csiUnmapper.csiClient = csiMapper.csiClient
- globalMapPath, err := csiUnmapper.GetGlobalMapPath(spec)
- if err != nil {
- t.Fatalf("unmapper failed to GetGlobalMapPath: %v", err)
- }
- err = csiUnmapper.UnmapPodDevice()
- if err != nil {
- t.Errorf("unmapper failed to call UnmapPodDevice: %v", err)
- }
- // GenerateUnmapDeviceFunc uses "" as pod UUID, it is global operation over all pods that used the volume
- unmapper, err = plug.NewBlockVolumeUnmapper(pv.ObjectMeta.Name, "")
- if err != nil {
- t.Fatalf("failed to make a new Unmapper: %v", err)
- }
- csiUnmapper = unmapper.(*csiBlockMapper)
- csiUnmapper.csiClient = csiMapper.csiClient
- err = csiUnmapper.TearDownDevice(globalMapPath, "/dev/test")
- if err != nil {
- t.Fatal(err)
- }
- pubs := csiUnmapper.csiClient.(*fakeCsiDriverClient).nodeClient.GetNodePublishedVolumes()
- if _, ok := pubs[csiUnmapper.volumeID]; ok {
- t.Error("csi server may not have received NodeUnpublishVolume call")
- }
- vols := csiUnmapper.csiClient.(*fakeCsiDriverClient).nodeClient.GetNodeStagedVolumes()
- if _, ok := vols[csiUnmapper.volumeID]; ok {
- t.Error("csi server may not have received NodeUnstageVolume call")
- }
- // Check that all metadata / staging / publish directories were deleted
- dataDir := getVolumeDeviceDataDir(pv.ObjectMeta.Name, plug.host)
- if _, err := os.Stat(dataDir); err == nil {
- t.Errorf("volume publish data directory %s was not deleted", dataDir)
- }
- devDir := getVolumeDeviceDataDir(pv.ObjectMeta.Name, plug.host)
- if _, err := os.Stat(devDir); err == nil {
- t.Errorf("volume publish device directory %s was not deleted", devDir)
- }
- if _, err := os.Stat(publishPath); err == nil {
- t.Errorf("volume publish path %s was not deleted", publishPath)
- }
- publishDir := filepath.Dir(publishPath)
- if _, err := os.Stat(publishDir); err == nil {
- t.Errorf("volume publish parent directory %s was not deleted", publishDir)
- }
- if _, err := os.Stat(stagingPath); err == nil {
- t.Errorf("volume staging path %s was not deleted", stagingPath)
- }
- }
|