Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CreateVolumeRequest respects the topology requirements of the node #199

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 38 additions & 22 deletions pkg/sanity/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,21 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {

It("should return appropriate values (no optional values added)", func() {

By("getting node information")
ni, err := n.NodeGetInfo(
context.Background(),
&csi.NodeGetInfoRequest{})
Expect(err).NotTo(HaveOccurred())
Expect(ni).NotTo(BeNil())
Expect(ni.GetNodeId()).NotTo(BeEmpty())

var accReqs *csi.TopologyRequirement
if ni.AccessibleTopology != nil {
accReqs = &csi.TopologyRequirement{
Requisite: []*csi.Topology{ni.AccessibleTopology},
}
}

// Create Volume First
By("creating a single node writer volume")
name := UniqueString("sanity-controller-publish")
Expand All @@ -1138,6 +1153,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
AccessibilityRequirements: accReqs,
},
)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -1146,22 +1162,14 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})

By("getting a node id")
nid, err := n.NodeGetInfo(
context.Background(),
&csi.NodeGetInfoRequest{})
Expect(err).NotTo(HaveOccurred())
Expect(nid).NotTo(BeNil())
Expect(nid.GetNodeId()).NotTo(BeEmpty())

// ControllerPublishVolume
By("calling controllerpublish on that volume")

conpubvol, err := c.ControllerPublishVolume(
context.Background(),
&csi.ControllerPublishVolumeRequest{
VolumeId: vol.GetVolume().GetVolumeId(),
NodeId: nid.GetNodeId(),
NodeId: ni.GetNodeId(),
VolumeCapability: &csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{
Mount: &csi.VolumeCapability_MountVolume{},
Expand All @@ -1175,7 +1183,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
)
Expect(err).NotTo(HaveOccurred())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: nid.GetNodeId()})
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: ni.GetNodeId()})
Expect(conpubvol).NotTo(BeNil())

By("cleaning up unpublishing the volume")
Expand All @@ -1185,7 +1193,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
&csi.ControllerUnpublishVolumeRequest{
VolumeId: vol.GetVolume().GetVolumeId(),
// NodeID is optional in ControllerUnpublishVolume
NodeId: nid.GetNodeId(),
NodeId: ni.GetNodeId(),
Secrets: sc.Secrets.ControllerUnpublishVolumeSecret,
},
)
Expand Down Expand Up @@ -1477,6 +1485,21 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
By("creating a single node writer volume")
name := UniqueString("sanity-controller-unpublish")

By("getting node information")
ni, err := n.NodeGetInfo(
context.Background(),
&csi.NodeGetInfoRequest{})
Expect(err).NotTo(HaveOccurred())
Expect(ni).NotTo(BeNil())
Expect(ni.GetNodeId()).NotTo(BeEmpty())

var accReqs *csi.TopologyRequirement
if ni.AccessibleTopology != nil {
accReqs = &csi.TopologyRequirement{
Requisite: []*csi.Topology{ni.AccessibleTopology},
}
}

vol, err := c.CreateVolume(
context.Background(),
&csi.CreateVolumeRequest{
Expand All @@ -1493,6 +1516,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
AccessibilityRequirements: accReqs,
},
)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -1501,22 +1525,14 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})

By("getting a node id")
nid, err := n.NodeGetInfo(
context.Background(),
&csi.NodeGetInfoRequest{})
Expect(err).NotTo(HaveOccurred())
Expect(nid).NotTo(BeNil())
Expect(nid.GetNodeId()).NotTo(BeEmpty())

// ControllerPublishVolume
By("calling controllerpublish on that volume")

conpubvol, err := c.ControllerPublishVolume(
context.Background(),
&csi.ControllerPublishVolumeRequest{
VolumeId: vol.GetVolume().GetVolumeId(),
NodeId: nid.GetNodeId(),
NodeId: ni.GetNodeId(),
VolumeCapability: &csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{
Mount: &csi.VolumeCapability_MountVolume{},
Expand All @@ -1530,7 +1546,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
)
Expect(err).NotTo(HaveOccurred())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: nid.GetNodeId()})
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: ni.GetNodeId()})
Expect(conpubvol).NotTo(BeNil())

// ControllerUnpublishVolume
Expand All @@ -1541,7 +1557,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
&csi.ControllerUnpublishVolumeRequest{
VolumeId: vol.GetVolume().GetVolumeId(),
// NodeID is optional in ControllerUnpublishVolume
NodeId: nid.GetNodeId(),
NodeId: ni.GetNodeId(),
Secrets: sc.Secrets.ControllerUnpublishVolumeSecret,
},
)
Expand Down
30 changes: 19 additions & 11 deletions pkg/sanity/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,21 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
It("should work", func() {
name := UniqueString("sanity-node-full")

By("getting node information")
ni, err := c.NodeGetInfo(
context.Background(),
&csi.NodeGetInfoRequest{})
Expect(err).NotTo(HaveOccurred())
Expect(ni).NotTo(BeNil())
Expect(ni.GetNodeId()).NotTo(BeEmpty())

var accReqs *csi.TopologyRequirement
if ni.AccessibleTopology != nil {
accReqs = &csi.TopologyRequirement{
Requisite: []*csi.Topology{ni.AccessibleTopology},
}
}

// Create Volume First
By("creating a single node writer volume")
vol, err := s.CreateVolume(
Expand All @@ -643,6 +658,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
},
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
AccessibilityRequirements: accReqs,
},
)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -651,14 +667,6 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})

By("getting a node id")
nid, err := c.NodeGetInfo(
context.Background(),
&csi.NodeGetInfoRequest{})
Expect(err).NotTo(HaveOccurred())
Expect(nid).NotTo(BeNil())
Expect(nid.GetNodeId()).NotTo(BeEmpty())

var conpubvol *csi.ControllerPublishVolumeResponse
if controllerPublishSupported {
By("controller publishing volume")
Expand All @@ -667,7 +675,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
context.Background(),
&csi.ControllerPublishVolumeRequest{
VolumeId: vol.GetVolume().GetVolumeId(),
NodeId: nid.GetNodeId(),
NodeId: ni.GetNodeId(),
VolumeCapability: &csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{
Mount: &csi.VolumeCapability_MountVolume{},
Expand All @@ -682,7 +690,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
},
)
Expect(err).NotTo(HaveOccurred())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: nid.GetNodeId()})
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: ni.GetNodeId()})
Expect(conpubvol).NotTo(BeNil())
}
// NodeStageVolume
Expand Down Expand Up @@ -782,7 +790,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
context.Background(),
&csi.ControllerUnpublishVolumeRequest{
VolumeId: vol.GetVolume().GetVolumeId(),
NodeId: nid.GetNodeId(),
NodeId: ni.GetNodeId(),
Secrets: sc.Secrets.ControllerUnpublishVolumeSecret,
},
)
Expand Down