Skip to content
Open
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
16 changes: 12 additions & 4 deletions agent/csi/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,18 @@ func (np *nodePlugin) makeSecrets(v *api.VolumeAssignment) map[string]string {
// makeNodeInfo converts a csi.NodeGetInfoResponse object into a swarmkit NodeCSIInfo
// object.
func makeNodeInfo(csiNodeInfo *csi.NodeGetInfoResponse) *api.NodeCSIInfo {
return &api.NodeCSIInfo{
NodeID: csiNodeInfo.NodeId,
MaxVolumesPerNode: csiNodeInfo.MaxVolumesPerNode,
}
nodeInfo := &api.NodeCSIInfo{
NodeID: csiNodeInfo.NodeId,
MaxVolumesPerNode: csiNodeInfo.MaxVolumesPerNode,
}

if topology := csiNodeInfo.GetAccessibleTopology(); topology != nil {
nodeInfo.AccessibleTopology = &api.Topology{
Segments: topology.GetSegments(),
}
}

return nodeInfo
}

// stagePath returns the staging path for a given volume assignment
Expand Down
25 changes: 25 additions & 0 deletions agent/csi/plugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net"
"testing"

"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/testutils"

Expand All @@ -27,6 +28,30 @@ func newVolumeClient(name string, nodeID string) *nodePlugin {
return n
}

func TestMakeNodeInfo(t *testing.T) {
csiNodeInfo := &csi.NodeGetInfoResponse{
NodeId: "node-1",
MaxVolumesPerNode: 26,
AccessibleTopology: &csi.Topology{
Segments: map[string]string{
"topology.kubernetes.io/zone": "eu-central-1a",
},
},
}

expected := &api.NodeCSIInfo{
NodeID: "node-1",
MaxVolumesPerNode: 26,
AccessibleTopology: &api.Topology{
Segments: map[string]string{
"topology.kubernetes.io/zone": "eu-central-1a",
},
},
}

assert.Equal(t, expected, makeNodeInfo(csiNodeInfo))
}

func TestNodeStageVolume(t *testing.T) {
plugin := "plugin-1"
node := "node-1"
Expand Down