Skip to content

Commit

Permalink
Merge pull request #200 from alexanderKhaustov/create-volumes-with-to…
Browse files Browse the repository at this point in the history
…pology

CreateVolume respects the topology requirements of the node
  • Loading branch information
k8s-ci-robot authored May 14, 2019
2 parents 3678ec3 + ccbd7cd commit 6738ab2
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 39 deletions.
74 changes: 48 additions & 26 deletions pkg/sanity/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1119,8 +1119,26 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
})

// CSI spec poses no specific requirements for the cluster/storage setups that a SP MUST support. To perform
// meaningful checks the following test assumes that topology-aware provisioning on a single node setup is supported
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 {
// Topology requirements are honored if provided by the driver
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 @@ -1139,8 +1157,9 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
},
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
AccessibilityRequirements: accReqs,
},
)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -1149,22 +1168,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 @@ -1178,7 +1189,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 @@ -1188,7 +1199,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 @@ -1474,12 +1485,30 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
})

// CSI spec poses no specific requirements for the cluster/storage setups that a SP MUST support. To perform
// meaningful checks the following test assumes that topology-aware provisioning on a single node setup is supported
It("should return appropriate values (no optional values added)", func() {

// Create Volume First
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 {
// Topology requirements are honored if provided by the driver
accReqs = &csi.TopologyRequirement{
Requisite: []*csi.Topology{ni.AccessibleTopology},
}
}

vol, err := c.CreateVolume(
context.Background(),
&csi.CreateVolumeRequest{
Expand All @@ -1494,8 +1523,9 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
},
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
AccessibilityRequirements: accReqs,
},
)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -1504,22 +1534,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 @@ -1533,7 +1555,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 @@ -1544,7 +1566,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
37 changes: 24 additions & 13 deletions pkg/sanity/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,27 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {

})

// CSI spec poses no specific requirements for the cluster/storage setups that a SP MUST support. To perform
// meaningful checks the following test assumes that topology-aware provisioning on a single node setup is supported
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 {
// Topology requirements are honored if provided by the driver
accReqs = &csi.TopologyRequirement{
Requisite: []*csi.Topology{ni.AccessibleTopology},
}
}

// Create Volume First
By("creating a single node writer volume")
vol, err := s.CreateVolume(
Expand All @@ -641,8 +659,9 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
},
},
},
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
AccessibilityRequirements: accReqs,
},
)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -651,14 +670,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 +678,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 +693,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 +793,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

0 comments on commit 6738ab2

Please sign in to comment.