Skip to content

Commit 155cf95

Browse files
committed
sanity: test NOT_FOUND on NodePublishVolume
According to the CSI spec, a plugin must return a `NOT_FOUND` error when `NodePublishVolume` is called with a `volume_id` of a volume that does not (or no longer?) exist. The `sanity` package has a test asserting this `NOT_FOUND` is returned on `NodeUnpublishVolume`, but not for `NodePublishVolume`. This patch adds this for completeness. See: https://github.com/container-storage-interface/spec/blob/87a27a2496565857ed564284eaa762587feb9453/spec.md#nodepublishvolume-errors
1 parent 09a5b85 commit 155cf95

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pkg/sanity/node.go

+22
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,28 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {
391391
Expect(ok).To(BeTrue())
392392
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
393393
})
394+
395+
It("should fail when the volume is missing", func() {
396+
stagingPath := ""
397+
if nodeStageSupported {
398+
stagingPath = sc.StagingPath
399+
}
400+
401+
_, err := c.NodePublishVolume(
402+
context.Background(),
403+
&csi.NodePublishVolumeRequest{
404+
VolumeId: sc.Config.IDGen.GenerateUniqueValidVolumeID(),
405+
VolumeCapability: TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER),
406+
StagingTargetPath: stagingPath,
407+
TargetPath: sc.TargetPath + "/target",
408+
Secrets: sc.Secrets.NodePublishVolumeSecret,
409+
})
410+
Expect(err).To(HaveOccurred())
411+
412+
serverError, ok := status.FromError(err)
413+
Expect(ok).To(BeTrue())
414+
Expect(serverError.Code()).To(Equal(codes.NotFound))
415+
})
394416
})
395417

396418
Describe("NodeUnpublishVolume", func() {

0 commit comments

Comments
 (0)