diff --git a/api/cloud-resources/v1beta1/gcpnfsvolume_types.go b/api/cloud-resources/v1beta1/gcpnfsvolume_types.go index b13e63545..bc864ad98 100644 --- a/api/cloud-resources/v1beta1/gcpnfsvolume_types.go +++ b/api/cloud-resources/v1beta1/gcpnfsvolume_types.go @@ -68,8 +68,10 @@ const ( // +kubebuilder:validation:XValidation:rule=(self.tier != "ZONAL" || self.tier == "ZONAL" && size(self.fileShareName) <= 64), message="ZONAL tier fileShareName length must be 64 or less characters" // +kubebuilder:validation:XValidation:rule=(self.tier != "BASIC_SSD" || self.tier == "BASIC_SSD" && self.capacityGb >= 2560 && self.capacityGb <= 65400), message="BASIC_SSD tier capacityGb must be between 2560 and 65400" // +kubebuilder:validation:XValidation:rule=(self.tier != "BASIC_SSD" || self.tier == "BASIC_SSD" && size(self.fileShareName) <= 16), message="BASIC_SSD tier fileShareName length must be 16 or less characters" +// +kubebuilder:validation:XValidation:rule=(self.tier != "BASIC_SSD" || self.tier == "BASIC_SSD" && self.capacityGb >= oldSelf.capacityGb), message="BASIC_SSD tier capacityGb cannot be reduced" // +kubebuilder:validation:XValidation:rule=(self.tier != "BASIC_HDD" || self.tier == "BASIC_HDD" && self.capacityGb >= 1024 && self.capacityGb <= 65400), message="BASIC_HDD tier capacityGb must be between 1024 and 65400" // +kubebuilder:validation:XValidation:rule=(self.tier != "BASIC_HDD" || self.tier == "BASIC_HDD" && size(self.fileShareName) <= 16), message="BASIC_HDD tier fileShareName length must be 16 or less characters" +// +kubebuilder:validation:XValidation:rule=(self.tier != "BASIC_HDD" || self.tier == "BASIC_HDD" && self.capacityGb >= oldSelf.capacityGb), message="BASIC_HDD tier capacityGb cannot be reduced" type GcpNfsVolumeSpec struct { // +optional // +kubebuilder:validation:XValidation:rule=(self == oldSelf), message="IpRange is immutable." diff --git a/config/crd/bases/cloud-resources.kyma-project.io_gcpnfsvolumes.yaml b/config/crd/bases/cloud-resources.kyma-project.io_gcpnfsvolumes.yaml index 495b62d4d..76d3c1497 100644 --- a/config/crd/bases/cloud-resources.kyma-project.io_gcpnfsvolumes.yaml +++ b/config/crd/bases/cloud-resources.kyma-project.io_gcpnfsvolumes.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.16.5 - cloud-resources.kyma-project.io/version: v0.0.7 + cloud-resources.kyma-project.io/version: v0.0.8 name: gcpnfsvolumes.cloud-resources.kyma-project.io spec: group: cloud-resources.kyma-project.io @@ -153,10 +153,14 @@ spec: rule: (self.tier != "BASIC_SSD" || self.tier == "BASIC_SSD" && self.capacityGb >= 2560 && self.capacityGb <= 65400) - message: BASIC_SSD tier fileShareName length must be 16 or less characters rule: (self.tier != "BASIC_SSD" || self.tier == "BASIC_SSD" && size(self.fileShareName) <= 16) + - message: BASIC_SSD tier capacityGb cannot be reduced + rule: (self.tier != "BASIC_SSD" || self.tier == "BASIC_SSD" && self.capacityGb >= oldSelf.capacityGb) - message: BASIC_HDD tier capacityGb must be between 1024 and 65400 rule: (self.tier != "BASIC_HDD" || self.tier == "BASIC_HDD" && self.capacityGb >= 1024 && self.capacityGb <= 65400) - message: BASIC_HDD tier fileShareName length must be 16 or less characters rule: (self.tier != "BASIC_HDD" || self.tier == "BASIC_HDD" && size(self.fileShareName) <= 16) + - message: BASIC_HDD tier capacityGb cannot be reduced + rule: (self.tier != "BASIC_HDD" || self.tier == "BASIC_HDD" && self.capacityGb >= oldSelf.capacityGb) status: description: GcpNfsVolumeStatus defines the observed state of GcpNfsVolume properties: diff --git a/config/dist/skr/crd/bases/providers/gcp/cloud-resources.kyma-project.io_gcpnfsvolumes.yaml b/config/dist/skr/crd/bases/providers/gcp/cloud-resources.kyma-project.io_gcpnfsvolumes.yaml index 495b62d4d..76d3c1497 100644 --- a/config/dist/skr/crd/bases/providers/gcp/cloud-resources.kyma-project.io_gcpnfsvolumes.yaml +++ b/config/dist/skr/crd/bases/providers/gcp/cloud-resources.kyma-project.io_gcpnfsvolumes.yaml @@ -4,7 +4,7 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.16.5 - cloud-resources.kyma-project.io/version: v0.0.7 + cloud-resources.kyma-project.io/version: v0.0.8 name: gcpnfsvolumes.cloud-resources.kyma-project.io spec: group: cloud-resources.kyma-project.io @@ -153,10 +153,14 @@ spec: rule: (self.tier != "BASIC_SSD" || self.tier == "BASIC_SSD" && self.capacityGb >= 2560 && self.capacityGb <= 65400) - message: BASIC_SSD tier fileShareName length must be 16 or less characters rule: (self.tier != "BASIC_SSD" || self.tier == "BASIC_SSD" && size(self.fileShareName) <= 16) + - message: BASIC_SSD tier capacityGb cannot be reduced + rule: (self.tier != "BASIC_SSD" || self.tier == "BASIC_SSD" && self.capacityGb >= oldSelf.capacityGb) - message: BASIC_HDD tier capacityGb must be between 1024 and 65400 rule: (self.tier != "BASIC_HDD" || self.tier == "BASIC_HDD" && self.capacityGb >= 1024 && self.capacityGb <= 65400) - message: BASIC_HDD tier fileShareName length must be 16 or less characters rule: (self.tier != "BASIC_HDD" || self.tier == "BASIC_HDD" && size(self.fileShareName) <= 16) + - message: BASIC_HDD tier capacityGb cannot be reduced + rule: (self.tier != "BASIC_HDD" || self.tier == "BASIC_HDD" && self.capacityGb >= oldSelf.capacityGb) status: description: GcpNfsVolumeStatus defines the observed state of GcpNfsVolume properties: diff --git a/config/patchAfterMakeManifests.sh b/config/patchAfterMakeManifests.sh index a34c44353..b0f75dbc7 100755 --- a/config/patchAfterMakeManifests.sh +++ b/config/patchAfterMakeManifests.sh @@ -9,7 +9,7 @@ yq -i '.metadata.annotations."cloud-resources.kyma-project.io/version" = "v0.1.1 yq -i '.metadata.annotations."cloud-resources.kyma-project.io/version" = "v0.0.3"' $SCRIPT_DIR/crd/bases/cloud-resources.kyma-project.io_awsnfsvolumes.yaml yq -i '.metadata.annotations."cloud-resources.kyma-project.io/version" = "v0.0.3"' $SCRIPT_DIR/crd/bases/cloud-resources.kyma-project.io_awsnfsvolumebackups.yaml yq -i '.metadata.annotations."cloud-resources.kyma-project.io/version" = "v0.0.16"' $SCRIPT_DIR/crd/bases/cloud-resources.kyma-project.io_awsredisinstances.yaml -yq -i '.metadata.annotations."cloud-resources.kyma-project.io/version" = "v0.0.7"' $SCRIPT_DIR/crd/bases/cloud-resources.kyma-project.io_gcpnfsvolumes.yaml +yq -i '.metadata.annotations."cloud-resources.kyma-project.io/version" = "v0.0.8"' $SCRIPT_DIR/crd/bases/cloud-resources.kyma-project.io_gcpnfsvolumes.yaml yq -i '.metadata.annotations."cloud-resources.kyma-project.io/version" = "v0.0.18"' $SCRIPT_DIR/crd/bases/cloud-resources.kyma-project.io_gcpredisinstances.yaml yq -i '.metadata.annotations."cloud-resources.kyma-project.io/version" = "v0.0.2"' $SCRIPT_DIR/crd/bases/cloud-resources.kyma-project.io_azurevpcpeerings.yaml yq -i '.metadata.annotations."cloud-resources.kyma-project.io/version" = "v0.0.54"' $SCRIPT_DIR/crd/bases/cloud-resources.kyma-project.io_azureredisinstances.yaml diff --git a/internal/api-tests/skr_gcpnfsvolume_test.go b/internal/api-tests/skr_gcpnfsvolume_test.go index e95d739c2..bdd3b6472 100644 --- a/internal/api-tests/skr_gcpnfsvolume_test.go +++ b/internal/api-tests/skr_gcpnfsvolume_test.go @@ -77,6 +77,20 @@ var _ = Describe("Feature: SKR GcpNfsVolume", Ordered, func() { newTestGcpNfsVolumeBuilder().WithTier(tier).WithCapacityGb(1024).WithFileShareName(fileShareName65char), fmt.Sprintf("%s tier fileShareName length must be 64 or less characters", tier), ) + canChangeSkr( + fmt.Sprintf("GcpNfsVolume %s tier instance capacity can be increased", tier), + newTestGcpNfsVolumeBuilder().WithTier(tier).WithCapacityGb(1024).WithValidFileShareName(), + func(b Builder[*cloudresourcesv1beta1.GcpNfsVolume]) { + b.(*testGcpNfsVolumeBuilder).WithCapacityGb(1280) + }, + ) + canChangeSkr( + fmt.Sprintf("GcpNfsVolume %s tier instance capacity can be reduced", tier), + newTestGcpNfsVolumeBuilder().WithTier(tier).WithCapacityGb(1280).WithValidFileShareName(), + func(b Builder[*cloudresourcesv1beta1.GcpNfsVolume]) { + b.(*testGcpNfsVolumeBuilder).WithCapacityGb(1024) + }, + ) } for _, validCapacity := range []int{2560, 2561, 65399, 65400} { @@ -97,6 +111,21 @@ var _ = Describe("Feature: SKR GcpNfsVolume", Ordered, func() { newTestGcpNfsVolumeBuilder().WithTier(cloudresourcesv1beta1.BASIC_SSD).WithCapacityGb(1024).WithFileShareName(fileShareName17char), "BASIC_SSD tier fileShareName length must be 16 or less characters", ) + canChangeSkr( + "GcpNfsVolume BASIC_SSD tier instance capacity can be increased", + newTestGcpNfsVolumeBuilder().WithTier(cloudresourcesv1beta1.BASIC_SSD).WithCapacityGb(2560).WithValidFileShareName(), + func(b Builder[*cloudresourcesv1beta1.GcpNfsVolume]) { + b.(*testGcpNfsVolumeBuilder).WithCapacityGb(2561) + }, + ) + canNotChangeSkr( + "GcpNfsVolume BASIC_SSD tier instance capacity can not be reduced", + newTestGcpNfsVolumeBuilder().WithTier(cloudresourcesv1beta1.BASIC_SSD).WithCapacityGb(2561).WithValidFileShareName(), + func(b Builder[*cloudresourcesv1beta1.GcpNfsVolume]) { + b.(*testGcpNfsVolumeBuilder).WithCapacityGb(2560) + }, + "BASIC_SSD tier capacityGb cannot be reduced", + ) for _, validCapacity := range []int{1024, 1025, 65399, 65400} { canCreateSkr( @@ -116,6 +145,21 @@ var _ = Describe("Feature: SKR GcpNfsVolume", Ordered, func() { newTestGcpNfsVolumeBuilder().WithTier(cloudresourcesv1beta1.BASIC_HDD).WithCapacityGb(1024).WithFileShareName(fileShareName17char), "BASIC_HDD tier fileShareName length must be 16 or less characters", ) + canChangeSkr( + "GcpNfsVolume BASIC_HDD tier instance capacity can be increased", + newTestGcpNfsVolumeBuilder().WithTier(cloudresourcesv1beta1.BASIC_HDD).WithCapacityGb(1024).WithValidFileShareName(), + func(b Builder[*cloudresourcesv1beta1.GcpNfsVolume]) { + b.(*testGcpNfsVolumeBuilder).WithCapacityGb(1025) + }, + ) + canNotChangeSkr( + "GcpNfsVolume BASIC_HDD tier instance capacity can not be reduced", + newTestGcpNfsVolumeBuilder().WithTier(cloudresourcesv1beta1.BASIC_HDD).WithCapacityGb(1025).WithValidFileShareName(), + func(b Builder[*cloudresourcesv1beta1.GcpNfsVolume]) { + b.(*testGcpNfsVolumeBuilder).WithCapacityGb(1024) + }, + "BASIC_HDD tier capacityGb cannot be reduced", + ) for _, removedTier := range []string{"STANDARD", "PREMIUM", "HIGH_SCALE_SSD", "ENTERPRISE"} { canNotCreateSkr(