Merge pull request #45802 from dperny/fix-missing-csi-topology
Fix missing Topology in NodeCSIInfo
This commit is contained in:
commit
7dd547c5ff
2 changed files with 73 additions and 6 deletions
|
@ -58,13 +58,20 @@ func NodeFromGRPC(n swarmapi.Node) types.Node {
|
||||||
}
|
}
|
||||||
for _, csi := range n.Description.CSIInfo {
|
for _, csi := range n.Description.CSIInfo {
|
||||||
if csi != nil {
|
if csi != nil {
|
||||||
node.Description.CSIInfo = append(
|
convertedInfo := types.NodeCSIInfo{
|
||||||
node.Description.CSIInfo,
|
|
||||||
types.NodeCSIInfo{
|
|
||||||
PluginName: csi.PluginName,
|
PluginName: csi.PluginName,
|
||||||
NodeID: csi.NodeID,
|
NodeID: csi.NodeID,
|
||||||
MaxVolumesPerNode: csi.MaxVolumesPerNode,
|
MaxVolumesPerNode: csi.MaxVolumesPerNode,
|
||||||
},
|
}
|
||||||
|
|
||||||
|
if csi.AccessibleTopology != nil {
|
||||||
|
convertedInfo.AccessibleTopology = &types.Topology{
|
||||||
|
Segments: csi.AccessibleTopology.Segments,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
node.Description.CSIInfo = append(
|
||||||
|
node.Description.CSIInfo, convertedInfo,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
60
daemon/cluster/convert/node_test.go
Normal file
60
daemon/cluster/convert/node_test.go
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
package convert
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
types "github.com/docker/docker/api/types/swarm"
|
||||||
|
swarmapi "github.com/moby/swarmkit/v2/api"
|
||||||
|
"gotest.tools/v3/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestNodeCSIInfoFromGRPC tests that conversion of the NodeCSIInfo from the
|
||||||
|
// gRPC to the Docker types is correct.
|
||||||
|
func TestNodeCSIInfoFromGRPC(t *testing.T) {
|
||||||
|
node := &swarmapi.Node{
|
||||||
|
ID: "someID",
|
||||||
|
Description: &swarmapi.NodeDescription{
|
||||||
|
CSIInfo: []*swarmapi.NodeCSIInfo{
|
||||||
|
&swarmapi.NodeCSIInfo{
|
||||||
|
PluginName: "plugin1",
|
||||||
|
NodeID: "p1n1",
|
||||||
|
MaxVolumesPerNode: 1,
|
||||||
|
},
|
||||||
|
&swarmapi.NodeCSIInfo{
|
||||||
|
PluginName: "plugin2",
|
||||||
|
NodeID: "p2n1",
|
||||||
|
MaxVolumesPerNode: 2,
|
||||||
|
AccessibleTopology: &swarmapi.Topology{
|
||||||
|
Segments: map[string]string{
|
||||||
|
"a": "1",
|
||||||
|
"b": "2",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
expected := []types.NodeCSIInfo{
|
||||||
|
{
|
||||||
|
PluginName: "plugin1",
|
||||||
|
NodeID: "p1n1",
|
||||||
|
MaxVolumesPerNode: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PluginName: "plugin2",
|
||||||
|
NodeID: "p2n1",
|
||||||
|
MaxVolumesPerNode: 2,
|
||||||
|
AccessibleTopology: &types.Topology{
|
||||||
|
Segments: map[string]string{
|
||||||
|
"a": "1",
|
||||||
|
"b": "2",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
actual := NodeFromGRPC(*node)
|
||||||
|
|
||||||
|
assert.DeepEqual(t, actual.Description.CSIInfo, expected)
|
||||||
|
}
|
Loading…
Reference in a new issue