diff --git a/pkg/sanity/cleanup.go b/pkg/sanity/cleanup.go new file mode 100644 index 00000000..b594c081 --- /dev/null +++ b/pkg/sanity/cleanup.go @@ -0,0 +1,126 @@ +/* +Copyright 2018 Intel Corporation + +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 sanity + +import ( + "context" + "log" + + "github.com/container-storage-interface/spec/lib/go/csi/v0" + + . "github.com/onsi/ginkgo" +) + +// VolumeInfo keeps track of the information needed to delete a volume. +type VolumeInfo struct { + // Node on which the volume was published, empty if none + // or publishing is not supported. + NodeID string + + // Volume ID assigned by CreateVolume. + VolumeID string +} + +// Cleanup keeps track of resources, in particular volumes, which need +// to be freed when testing is done. +type Cleanup struct { + Context *SanityContext + ControllerClient csi.ControllerClient + NodeClient csi.NodeClient + ControllerPublishSupported bool + NodeStageSupported bool + + // Maps from volume name to the node ID for which the volume + // is published and the volume ID. + volumes map[string]VolumeInfo +} + +// RegisterVolume adds or updates an entry for the volume with the +// given name. +func (cl *Cleanup) RegisterVolume(name string, info VolumeInfo) { + if cl.volumes == nil { + cl.volumes = make(map[string]VolumeInfo) + } + cl.volumes[name] = info +} + +// UnregisterVolume removes the entry for the volume with the +// given name, thus preventing all cleanup operations for it. +func (cl *Cleanup) UnregisterVolume(name string) { + if cl.volumes != nil { + delete(cl.volumes, name) + } +} + +// DeleteVolumes stops using the registered volumes and tries to delete all of them. +func (cl *Cleanup) DeleteVolumes() { + if cl.volumes == nil { + return + } + logger := log.New(GinkgoWriter, "cleanup: ", 0) + ctx := context.Background() + + for name, info := range cl.volumes { + logger.Printf("deleting %s = %s", name, info.VolumeID) + if _, err := cl.NodeClient.NodeUnpublishVolume( + ctx, + &csi.NodeUnpublishVolumeRequest{ + VolumeId: info.VolumeID, + TargetPath: cl.Context.Config.TargetPath, + }, + ); err != nil { + logger.Printf("warning: NodeUnpublishVolume: %s", err) + } + + if cl.NodeStageSupported { + if _, err := cl.NodeClient.NodeUnstageVolume( + ctx, + &csi.NodeUnstageVolumeRequest{ + VolumeId: info.VolumeID, + StagingTargetPath: cl.Context.Config.StagingPath, + }, + ); err != nil { + logger.Printf("warning: NodeUnstageVolume: %s", err) + } + } + + if cl.ControllerPublishSupported && info.NodeID != "" { + if _, err := cl.ControllerClient.ControllerUnpublishVolume( + ctx, + &csi.ControllerUnpublishVolumeRequest{ + VolumeId: info.VolumeID, + NodeId: info.NodeID, + ControllerUnpublishSecrets: cl.Context.Secrets.ControllerUnpublishVolumeSecret, + }, + ); err != nil { + logger.Printf("warning: ControllerUnpublishVolume: %s", err) + } + } + + if _, err := cl.ControllerClient.DeleteVolume( + ctx, + &csi.DeleteVolumeRequest{ + VolumeId: info.VolumeID, + ControllerDeleteSecrets: cl.Context.Secrets.DeleteVolumeSecret, + }, + ); err != nil { + logger.Printf("error: DeleteVolume: %s", err) + } + + cl.UnregisterVolume(name) + } +} diff --git a/pkg/sanity/controller.go b/pkg/sanity/controller.go index c4c6e337..f1d68706 100644 --- a/pkg/sanity/controller.go +++ b/pkg/sanity/controller.go @@ -73,11 +73,23 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { var ( c csi.ControllerClient n csi.NodeClient + + cl *Cleanup ) BeforeEach(func() { c = csi.NewControllerClient(sc.Conn) n = csi.NewNodeClient(sc.Conn) + + cl = &Cleanup{ + NodeClient: n, + ControllerClient: c, + Context: sc, + } + }) + + AfterEach(func() { + cl.DeleteVolumes() }) Describe("ControllerGetCapabilities", func() { @@ -213,6 +225,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { Expect(vol).NotTo(BeNil()) Expect(vol.GetVolume()).NotTo(BeNil()) Expect(vol.GetVolume().GetId()).NotTo(BeEmpty()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()}) By("cleaning up deleting the volume") @@ -224,6 +237,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) + cl.UnregisterVolume(name) }) It("should return appropriate values SingleNodeWriter WithCapacity 1Gi Type:Mount", func() { @@ -251,20 +265,17 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret, }, ) - if serverError, ok := status.FromError(err); ok { - if serverError.Code() == codes.OutOfRange || serverError.Code() == codes.Unimplemented { - Skip("Required bytes not supported") - } else { - Expect(err).NotTo(HaveOccurred()) - } - } else { - - Expect(err).NotTo(HaveOccurred()) - Expect(vol).NotTo(BeNil()) - Expect(vol.GetVolume()).NotTo(BeNil()) - Expect(vol.GetVolume().GetId()).NotTo(BeEmpty()) - Expect(vol.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", TestVolumeSize(sc))) + if serverError, ok := status.FromError(err); ok && + (serverError.Code() == codes.OutOfRange || serverError.Code() == codes.Unimplemented) { + Skip("Required bytes not supported") } + Expect(err).NotTo(HaveOccurred()) + Expect(vol).NotTo(BeNil()) + Expect(vol.GetVolume()).NotTo(BeNil()) + Expect(vol.GetVolume().GetId()).NotTo(BeEmpty()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()}) + Expect(vol.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", TestVolumeSize(sc))) + By("cleaning up deleting the volume") _, err = c.DeleteVolume( @@ -275,6 +286,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) + cl.UnregisterVolume(name) }) It("should not fail when requesting to create a volume with already exisiting name and same capacity.", func() { @@ -306,6 +318,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { Expect(vol1).NotTo(BeNil()) Expect(vol1.GetVolume()).NotTo(BeNil()) Expect(vol1.GetVolume().GetId()).NotTo(BeEmpty()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol1.GetVolume().GetId()}) Expect(vol1.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", size)) vol2, err := c.CreateVolume( @@ -345,6 +358,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) + cl.UnregisterVolume(name) }) It("should fail when requesting to create a volume with already exisiting name and different capacity.", func() { @@ -377,6 +391,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { Expect(vol1).NotTo(BeNil()) Expect(vol1.GetVolume()).NotTo(BeNil()) Expect(vol1.GetVolume().GetId()).NotTo(BeEmpty()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol1.GetVolume().GetId()}) size2 := 2 * TestVolumeSize(sc) _, err = c.CreateVolume( @@ -415,6 +430,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) + cl.UnregisterVolume(name) }) }) @@ -479,6 +495,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { Expect(vol).NotTo(BeNil()) Expect(vol.GetVolume()).NotTo(BeNil()) Expect(vol.GetVolume().GetId()).NotTo(BeEmpty()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()}) // Delete Volume By("deleting a volume") @@ -491,6 +508,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) + cl.UnregisterVolume(name) }) }) @@ -548,6 +566,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { Expect(vol).NotTo(BeNil()) Expect(vol.GetVolume()).NotTo(BeNil()) Expect(vol.GetVolume().GetId()).NotTo(BeEmpty()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()}) // ValidateVolumeCapabilities By("validating volume capabilities") @@ -580,6 +599,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) + cl.UnregisterVolume(name) }) It("should fail when the requested volume does not exist", func() { @@ -690,6 +710,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { Expect(vol).NotTo(BeNil()) Expect(vol.GetVolume()).NotTo(BeNil()) Expect(vol.GetVolume().GetId()).NotTo(BeEmpty()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()}) By("getting a node id") nid, err := n.NodeGetId( @@ -720,6 +741,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId(), NodeID: nid.GetNodeId()}) Expect(conpubvol).NotTo(BeNil()) By("cleaning up unpublishing the volume") @@ -746,6 +768,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) + cl.UnregisterVolume(name) }) It("should fail when the volume does not exist", func() { @@ -804,6 +827,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { Expect(vol).NotTo(BeNil()) Expect(vol.GetVolume()).NotTo(BeNil()) Expect(vol.GetVolume().GetId()).NotTo(BeEmpty()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()}) // ControllerPublishVolume By("calling controllerpublish on that volume") @@ -842,6 +866,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) + cl.UnregisterVolume(name) }) It("should fail when the volume is already published but is incompatible", func() { @@ -871,6 +896,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { Expect(vol).NotTo(BeNil()) Expect(vol.GetVolume()).NotTo(BeNil()) Expect(vol.GetVolume().GetId()).NotTo(BeEmpty()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()}) By("getting a node id") nid, err := n.NodeGetId( @@ -938,6 +964,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) + cl.UnregisterVolume(name) }) }) @@ -990,6 +1017,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { Expect(vol).NotTo(BeNil()) Expect(vol.GetVolume()).NotTo(BeNil()) Expect(vol.GetVolume().GetId()).NotTo(BeEmpty()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()}) By("getting a node id") nid, err := n.NodeGetId( @@ -1020,6 +1048,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId(), NodeID: nid.GetNodeId()}) Expect(conpubvol).NotTo(BeNil()) // ControllerUnpublishVolume @@ -1047,6 +1076,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) + cl.UnregisterVolume(name) }) }) }) diff --git a/pkg/sanity/node.go b/pkg/sanity/node.go index c44044b1..a98f5151 100644 --- a/pkg/sanity/node.go +++ b/pkg/sanity/node.go @@ -70,8 +70,9 @@ func isPluginCapabilitySupported(c csi.IdentityClient, var _ = DescribeSanity("Node Service", func(sc *SanityContext) { var ( - c csi.NodeClient - s csi.ControllerClient + cl *Cleanup + c csi.NodeClient + s csi.ControllerClient controllerPublishSupported bool nodeStageSupported bool @@ -89,6 +90,17 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) { err := createMountTargetLocation(sc.Config.StagingPath) Expect(err).NotTo(HaveOccurred()) } + cl = &Cleanup{ + Context: sc, + NodeClient: c, + ControllerClient: s, + ControllerPublishSupported: controllerPublishSupported, + NodeStageSupported: nodeStageSupported, + } + }) + + AfterEach(func() { + cl.DeleteVolumes() }) Describe("NodeGetCapabilities", func() { @@ -351,76 +363,102 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) { It("should work", func() { name := uniqueString("sanity-node-full") - testFullWorkflowSuccess(sc, s, c, name, controllerPublishSupported, nodeStageSupported) - }) -}) -// TODO: Tests for NodeStageVolume/NodeUnstageVolume -func testFullWorkflowSuccess(sc *SanityContext, s csi.ControllerClient, c csi.NodeClient, name string, controllerPublishSupported, nodeStageSupported bool) { - // Create Volume First - By("creating a single node writer volume") - vol, err := s.CreateVolume( - context.Background(), - &csi.CreateVolumeRequest{ - Name: name, - VolumeCapabilities: []*csi.VolumeCapability{ - { - AccessType: &csi.VolumeCapability_Mount{ - Mount: &csi.VolumeCapability_MountVolume{}, - }, - AccessMode: &csi.VolumeCapability_AccessMode{ - Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, + // Create Volume First + By("creating a single node writer volume") + vol, err := s.CreateVolume( + context.Background(), + &csi.CreateVolumeRequest{ + Name: name, + VolumeCapabilities: []*csi.VolumeCapability{ + { + AccessType: &csi.VolumeCapability_Mount{ + Mount: &csi.VolumeCapability_MountVolume{}, + }, + AccessMode: &csi.VolumeCapability_AccessMode{ + Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, + }, }, }, + ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret, }, - ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret, - }, - ) + ) + Expect(err).NotTo(HaveOccurred()) + Expect(vol).NotTo(BeNil()) + Expect(vol.GetVolume()).NotTo(BeNil()) + Expect(vol.GetVolume().GetId()).NotTo(BeEmpty()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()}) - Expect(err).NotTo(HaveOccurred()) - Expect(vol).NotTo(BeNil()) - Expect(vol.GetVolume()).NotTo(BeNil()) - Expect(vol.GetVolume().GetId()).NotTo(BeEmpty()) + By("getting a node id") + nid, err := c.NodeGetId( + context.Background(), + &csi.NodeGetIdRequest{}) + Expect(err).NotTo(HaveOccurred()) + Expect(nid).NotTo(BeNil()) + Expect(nid.GetNodeId()).NotTo(BeEmpty()) - By("getting a node id") - nid, err := c.NodeGetId( - context.Background(), - &csi.NodeGetIdRequest{}) - Expect(err).NotTo(HaveOccurred()) - Expect(nid).NotTo(BeNil()) - Expect(nid.GetNodeId()).NotTo(BeEmpty()) - var conpubvol *csi.ControllerPublishVolumeResponse - if controllerPublishSupported { - By("controller publishing volume") + var conpubvol *csi.ControllerPublishVolumeResponse + if controllerPublishSupported { + By("controller publishing volume") - conpubvol, err = s.ControllerPublishVolume( - context.Background(), - &csi.ControllerPublishVolumeRequest{ - VolumeId: vol.GetVolume().GetId(), - NodeId: nid.GetNodeId(), - VolumeCapability: &csi.VolumeCapability{ - AccessType: &csi.VolumeCapability_Mount{ - Mount: &csi.VolumeCapability_MountVolume{}, + conpubvol, err = s.ControllerPublishVolume( + context.Background(), + &csi.ControllerPublishVolumeRequest{ + VolumeId: vol.GetVolume().GetId(), + NodeId: nid.GetNodeId(), + VolumeCapability: &csi.VolumeCapability{ + AccessType: &csi.VolumeCapability_Mount{ + Mount: &csi.VolumeCapability_MountVolume{}, + }, + AccessMode: &csi.VolumeCapability_AccessMode{ + Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, + }, }, - AccessMode: &csi.VolumeCapability_AccessMode{ - Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, + VolumeAttributes: vol.GetVolume().GetAttributes(), + Readonly: false, + ControllerPublishSecrets: sc.Secrets.ControllerPublishVolumeSecret, + }, + ) + Expect(err).NotTo(HaveOccurred()) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId(), NodeID: nid.GetNodeId()}) + Expect(conpubvol).NotTo(BeNil()) + } + // NodeStageVolume + if nodeStageSupported { + By("node staging volume") + nodestagevol, err := c.NodeStageVolume( + context.Background(), + &csi.NodeStageVolumeRequest{ + VolumeId: vol.GetVolume().GetId(), + VolumeCapability: &csi.VolumeCapability{ + AccessType: &csi.VolumeCapability_Mount{ + Mount: &csi.VolumeCapability_MountVolume{}, + }, + AccessMode: &csi.VolumeCapability_AccessMode{ + Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, + }, }, + StagingTargetPath: sc.Config.StagingPath, + VolumeAttributes: vol.GetVolume().GetAttributes(), + PublishInfo: conpubvol.GetPublishInfo(), + NodeStageSecrets: sc.Secrets.NodeStageVolumeSecret, }, - VolumeAttributes: vol.GetVolume().GetAttributes(), - Readonly: false, - ControllerPublishSecrets: sc.Secrets.ControllerPublishVolumeSecret, - }, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(conpubvol).NotTo(BeNil()) - } - // NodeStageVolume - if nodeStageSupported { - By("node staging volume") - nodestagevol, err := c.NodeStageVolume( + ) + Expect(err).NotTo(HaveOccurred()) + Expect(nodestagevol).NotTo(BeNil()) + } + // NodePublishVolume + By("publishing the volume on a node") + var stagingPath string + if nodeStageSupported { + stagingPath = sc.Config.StagingPath + } + nodepubvol, err := c.NodePublishVolume( context.Background(), - &csi.NodeStageVolumeRequest{ - VolumeId: vol.GetVolume().GetId(), + &csi.NodePublishVolumeRequest{ + VolumeId: vol.GetVolume().GetId(), + TargetPath: sc.Config.TargetPath, + StagingTargetPath: stagingPath, VolumeCapability: &csi.VolumeCapability{ AccessType: &csi.VolumeCapability_Mount{ Mount: &csi.VolumeCapability_MountVolume{}, @@ -429,90 +467,62 @@ func testFullWorkflowSuccess(sc *SanityContext, s csi.ControllerClient, c csi.No Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, }, }, - StagingTargetPath: sc.Config.StagingPath, - VolumeAttributes: vol.GetVolume().GetAttributes(), - PublishInfo: conpubvol.GetPublishInfo(), - NodeStageSecrets: sc.Secrets.NodeStageVolumeSecret, + VolumeAttributes: vol.GetVolume().GetAttributes(), + PublishInfo: conpubvol.GetPublishInfo(), + NodePublishSecrets: sc.Secrets.NodePublishVolumeSecret, }, ) Expect(err).NotTo(HaveOccurred()) - Expect(nodestagevol).NotTo(BeNil()) - } - // NodePublishVolume - By("publishing the volume on a node") - var stagingPath string - if nodeStageSupported { - stagingPath = sc.Config.StagingPath - } - nodepubvol, err := c.NodePublishVolume( - context.Background(), - &csi.NodePublishVolumeRequest{ - VolumeId: vol.GetVolume().GetId(), - TargetPath: sc.Config.TargetPath, - StagingTargetPath: stagingPath, - VolumeCapability: &csi.VolumeCapability{ - AccessType: &csi.VolumeCapability_Mount{ - Mount: &csi.VolumeCapability_MountVolume{}, - }, - AccessMode: &csi.VolumeCapability_AccessMode{ - Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, - }, - }, - VolumeAttributes: vol.GetVolume().GetAttributes(), - PublishInfo: conpubvol.GetPublishInfo(), - NodePublishSecrets: sc.Secrets.NodePublishVolumeSecret, - }, - ) - Expect(err).NotTo(HaveOccurred()) - Expect(nodepubvol).NotTo(BeNil()) + Expect(nodepubvol).NotTo(BeNil()) - // NodeUnpublishVolume - By("cleaning up calling nodeunpublish") - nodeunpubvol, err := c.NodeUnpublishVolume( - context.Background(), - &csi.NodeUnpublishVolumeRequest{ - VolumeId: vol.GetVolume().GetId(), - TargetPath: sc.Config.TargetPath, - }) - Expect(err).NotTo(HaveOccurred()) - Expect(nodeunpubvol).NotTo(BeNil()) - - if nodeStageSupported { - By("cleaning up calling nodeunstage") - nodeunstagevol, err := c.NodeUnstageVolume( + // NodeUnpublishVolume + By("cleaning up calling nodeunpublish") + nodeunpubvol, err := c.NodeUnpublishVolume( context.Background(), - &csi.NodeUnstageVolumeRequest{ - VolumeId: vol.GetVolume().GetId(), - StagingTargetPath: sc.Config.StagingPath, - }, - ) + &csi.NodeUnpublishVolumeRequest{ + VolumeId: vol.GetVolume().GetId(), + TargetPath: sc.Config.TargetPath, + }) Expect(err).NotTo(HaveOccurred()) - Expect(nodeunstagevol).NotTo(BeNil()) - } + Expect(nodeunpubvol).NotTo(BeNil()) + + if nodeStageSupported { + By("cleaning up calling nodeunstage") + nodeunstagevol, err := c.NodeUnstageVolume( + context.Background(), + &csi.NodeUnstageVolumeRequest{ + VolumeId: vol.GetVolume().GetId(), + StagingTargetPath: sc.Config.StagingPath, + }, + ) + Expect(err).NotTo(HaveOccurred()) + Expect(nodeunstagevol).NotTo(BeNil()) + } + + if controllerPublishSupported { + By("cleaning up calling controllerunpublishing") + + controllerunpubvol, err := s.ControllerUnpublishVolume( + context.Background(), + &csi.ControllerUnpublishVolumeRequest{ + VolumeId: vol.GetVolume().GetId(), + NodeId: nid.GetNodeId(), + ControllerUnpublishSecrets: sc.Secrets.ControllerUnpublishVolumeSecret, + }, + ) + Expect(err).NotTo(HaveOccurred()) + Expect(controllerunpubvol).NotTo(BeNil()) + } - if controllerPublishSupported { - By("cleaning up calling controllerunpublishing") + By("cleaning up deleting the volume") - controllerunpubvol, err := s.ControllerUnpublishVolume( + _, err = s.DeleteVolume( context.Background(), - &csi.ControllerUnpublishVolumeRequest{ - VolumeId: vol.GetVolume().GetId(), - NodeId: nid.GetNodeId(), - ControllerUnpublishSecrets: sc.Secrets.ControllerUnpublishVolumeSecret, + &csi.DeleteVolumeRequest{ + VolumeId: vol.GetVolume().GetId(), + ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret, }, ) Expect(err).NotTo(HaveOccurred()) - Expect(controllerunpubvol).NotTo(BeNil()) - } - - By("cleaning up deleting the volume") - - _, err = s.DeleteVolume( - context.Background(), - &csi.DeleteVolumeRequest{ - VolumeId: vol.GetVolume().GetId(), - ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret, - }, - ) - Expect(err).NotTo(HaveOccurred()) -} + }) +})