Skip to content

Commit fc86783

Browse files
authored
Advertise online resize in CSI Identity server
1 parent 67a5426 commit fc86783

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

frontend/csi/identity_server.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ func (p *Plugin) GetPluginCapabilities(
7575
},
7676
},
7777
},
78+
{
79+
Type: &csi.PluginCapability_VolumeExpansion_{
80+
VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
81+
Type: csi.PluginCapability_VolumeExpansion_ONLINE,
82+
},
83+
},
84+
},
7885
}
7986

8087
// If topology is in use, add VOLUME_ACCESSIBILITY_CONSTRAINTS capability

frontend/csi/identity_server_test.go

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,33 @@ func TestGetPluginInfo(t *testing.T) {
116116

117117
func TestGetPluginCapabilities(t *testing.T) {
118118
testCases := []struct {
119-
name string
120-
topologyInUse bool
121-
expectedTypes []csi.PluginCapability_Service_Type
119+
name string
120+
topologyInUse bool
121+
expectedServiceTypes []csi.PluginCapability_Service_Type
122+
expectedExpansionTypes []csi.PluginCapability_VolumeExpansion_Type
122123
}{
123124
{
124125
name: "No Topology",
125126
topologyInUse: false,
126-
expectedTypes: []csi.PluginCapability_Service_Type{
127+
expectedServiceTypes: []csi.PluginCapability_Service_Type{
127128
csi.PluginCapability_Service_CONTROLLER_SERVICE,
128129
csi.PluginCapability_Service_GROUP_CONTROLLER_SERVICE,
129130
},
131+
expectedExpansionTypes: []csi.PluginCapability_VolumeExpansion_Type{
132+
csi.PluginCapability_VolumeExpansion_ONLINE,
133+
},
130134
},
131135
{
132136
name: "With Topology",
133137
topologyInUse: true,
134-
expectedTypes: []csi.PluginCapability_Service_Type{
138+
expectedServiceTypes: []csi.PluginCapability_Service_Type{
135139
csi.PluginCapability_Service_CONTROLLER_SERVICE,
136140
csi.PluginCapability_Service_GROUP_CONTROLLER_SERVICE,
137141
csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS,
138142
},
143+
expectedExpansionTypes: []csi.PluginCapability_VolumeExpansion_Type{
144+
csi.PluginCapability_VolumeExpansion_ONLINE,
145+
},
139146
},
140147
}
141148

@@ -145,13 +152,23 @@ func TestGetPluginCapabilities(t *testing.T) {
145152
topologyInUse: tc.topologyInUse,
146153
}
147154
resp, err := plugin.GetPluginCapabilities(context.Background(), &csi.GetPluginCapabilitiesRequest{})
155+
148156
assert.NoError(t, err)
149157
assert.NotNil(t, resp)
150-
var gotTypes []csi.PluginCapability_Service_Type
151-
for _, cap := range resp.Capabilities {
152-
gotTypes = append(gotTypes, cap.GetService().GetType())
158+
159+
var gotServiceTypes []csi.PluginCapability_Service_Type
160+
var gotExpansionTypes []csi.PluginCapability_VolumeExpansion_Type
161+
162+
for _, capability := range resp.Capabilities {
163+
if capability.GetService() != nil {
164+
gotServiceTypes = append(gotServiceTypes, capability.GetService().GetType())
165+
} else if capability.GetVolumeExpansion() != nil {
166+
gotExpansionTypes = append(gotExpansionTypes, capability.GetVolumeExpansion().GetType())
167+
}
153168
}
154-
assert.ElementsMatch(t, tc.expectedTypes, gotTypes)
169+
170+
assert.ElementsMatch(t, tc.expectedServiceTypes, gotServiceTypes)
171+
assert.ElementsMatch(t, tc.expectedExpansionTypes, gotExpansionTypes)
155172
})
156173
}
157174
}

0 commit comments

Comments
 (0)