Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 6f41a6f

Browse files
committed
feat: allow volume expansion
1 parent d406584 commit 6f41a6f

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

api/v1alpha1/addon_types.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ type StorageClassConfig struct {
178178

179179
// +optional
180180
VolumeBindingMode string `json:"volumeBindingMode,omitempty"`
181+
182+
// +optional
183+
AllowExpansion bool `json:"allowExpansion,omitempty"`
181184
}
182185

183186
func (StorageClassConfig) VariableSchema() clusterv1.VariableSchema {
@@ -192,7 +195,8 @@ func (StorageClassConfig) VariableSchema() clusterv1.VariableSchema {
192195
}
193196
return clusterv1.VariableSchema{
194197
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
195-
Type: "object",
198+
Type: "object",
199+
Required: []string{"name"},
196200
Properties: map[string]clusterv1.JSONSchemaProps{
197201
"name": {
198202
Type: "string",
@@ -215,6 +219,11 @@ func (StorageClassConfig) VariableSchema() clusterv1.VariableSchema {
215219
Enum: variables.MustMarshalValuesToEnumJSON(supportedBindingModes...),
216220
Default: variables.MustMarshal(VolumeBindingWaitForFirstConsumer),
217221
},
222+
"allowExpansion": {
223+
Type: "boolean",
224+
Default: variables.MustMarshal(false),
225+
Description: "If the storage class should allow volume expanding",
226+
},
218227
},
219228
},
220229
}
@@ -224,7 +233,8 @@ func (CSIProvider) VariableSchema() clusterv1.VariableSchema {
224233
supportedCSIProviders := []string{CSIProviderAWSEBS, CSIProviderNutanix}
225234
return clusterv1.VariableSchema{
226235
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
227-
Type: "object",
236+
Type: "object",
237+
Required: []string{"name", "strategy"},
228238
Properties: map[string]clusterv1.JSONSchemaProps{
229239
"name": {
230240
Description: "Name of the CSI Provider",
@@ -267,12 +277,14 @@ func (DefaultStorage) VariableSchema() clusterv1.VariableSchema {
267277
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
268278
Type: "object",
269279
Description: "A tuple of provider name and storage class ",
280+
Required: []string{"providerName", "storageClassConfigName"},
270281
Properties: map[string]clusterv1.JSONSchemaProps{
271282
"providerName": {
272283
Type: "string",
273284
Description: "Name of the CSI Provider for the default storage class",
274285
Enum: variables.MustMarshalValuesToEnumJSON(
275-
supportedCSIProviders...),
286+
supportedCSIProviders...,
287+
),
276288
},
277289
"storageClassConfigName": {
278290
Type: "string",

pkg/handlers/generic/lifecycle/utils/utils.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,11 @@ func CreateStorageClass(
191191
Name: storageConfig.Name,
192192
Namespace: defaultsNamespace,
193193
},
194-
Provisioner: string(provisionerName),
195-
Parameters: params,
196-
VolumeBindingMode: volumeBindingMode,
197-
ReclaimPolicy: reclaimPolicy,
194+
Provisioner: string(provisionerName),
195+
Parameters: params,
196+
VolumeBindingMode: volumeBindingMode,
197+
ReclaimPolicy: reclaimPolicy,
198+
AllowVolumeExpansion: ptr.To(storageConfig.AllowExpansion),
198199
}
199200
if isDefault {
200201
sc.ObjectMeta.Annotations = defaultStorageClassMap

pkg/handlers/generic/lifecycle/utils/utils_test.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func TestCreateStorageClass(t *testing.T) {
3232
ReclaimPolicy: v1alpha1.VolumeReclaimDelete,
3333
VolumeBindingMode: v1alpha1.VolumeBindingWaitForFirstConsumer,
3434
Parameters: nil,
35+
AllowExpansion: true,
3536
},
3637
expectedStorageClass: &storagev1.StorageClass{
3738
TypeMeta: metav1.TypeMeta{
@@ -42,10 +43,11 @@ func TestCreateStorageClass(t *testing.T) {
4243
Name: "aws-ebs",
4344
Namespace: "default",
4445
},
45-
Parameters: defaultAWSStorageClassParams,
46-
ReclaimPolicy: ptr.To(corev1.PersistentVolumeReclaimDelete),
47-
VolumeBindingMode: ptr.To(storagev1.VolumeBindingWaitForFirstConsumer),
48-
Provisioner: string(v1alpha1.AWSEBSProvisioner),
46+
Parameters: defaultAWSStorageClassParams,
47+
ReclaimPolicy: ptr.To(corev1.PersistentVolumeReclaimDelete),
48+
VolumeBindingMode: ptr.To(storagev1.VolumeBindingWaitForFirstConsumer),
49+
Provisioner: string(v1alpha1.AWSEBSProvisioner),
50+
AllowVolumeExpansion: ptr.To(true),
4951
},
5052
provisioner: v1alpha1.AWSEBSProvisioner,
5153
defaultsNamespace: "default",
@@ -84,9 +86,10 @@ func TestCreateStorageClass(t *testing.T) {
8486
"whitelistIPMode": "ENABLED",
8587
"whitelistIPAddr": "1.1.1.1",
8688
},
87-
ReclaimPolicy: ptr.To(corev1.PersistentVolumeReclaimDelete),
88-
VolumeBindingMode: ptr.To(storagev1.VolumeBindingWaitForFirstConsumer),
89-
Provisioner: string(v1alpha1.NutanixProvisioner),
89+
ReclaimPolicy: ptr.To(corev1.PersistentVolumeReclaimDelete),
90+
VolumeBindingMode: ptr.To(storagev1.VolumeBindingWaitForFirstConsumer),
91+
Provisioner: string(v1alpha1.NutanixProvisioner),
92+
AllowVolumeExpansion: ptr.To(false),
9093
},
9194
provisioner: v1alpha1.NutanixProvisioner,
9295
defaultsNamespace: "default",
@@ -107,9 +110,10 @@ func TestCreateStorageClass(t *testing.T) {
107110
Name: "nutanix-volumes",
108111
Namespace: "default",
109112
},
110-
ReclaimPolicy: ptr.To(corev1.PersistentVolumeReclaimDelete),
111-
VolumeBindingMode: ptr.To(storagev1.VolumeBindingWaitForFirstConsumer),
112-
Provisioner: string(v1alpha1.NutanixProvisioner),
113+
ReclaimPolicy: ptr.To(corev1.PersistentVolumeReclaimDelete),
114+
VolumeBindingMode: ptr.To(storagev1.VolumeBindingWaitForFirstConsumer),
115+
Provisioner: string(v1alpha1.NutanixProvisioner),
116+
AllowVolumeExpansion: ptr.To(false),
113117
},
114118
provisioner: v1alpha1.NutanixProvisioner,
115119
defaultsNamespace: "default",

0 commit comments

Comments
 (0)