Skip to content

Commit 734f0c7

Browse files
committed
WIP: Prevent quota reduction via CEL validation in StorageConsumer CRD
Signed-off-by: Oded Viner <[email protected]>
1 parent aaafa32 commit 734f0c7

File tree

6 files changed

+12
-0
lines changed

6 files changed

+12
-0
lines changed

api/v1alpha1/storageconsumer_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const (
3838
)
3939

4040
// StorageConsumerSpec defines the desired state of StorageConsumer
41+
// +kubebuilder:validation:XValidation:rule="self.storageQuotaInGiB >= oldSelf.storageQuotaInGiB",message="storageQuotaInGiB cannot be decreased on update"
4142
type StorageConsumerSpec struct {
4243
// Enable flag ignores a reconcile if set to false
4344
Enable bool `json:"enable,omitempty"`

config/crd/bases/ocs.openshift.io_storageconsumers.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ spec:
9898
type: object
9999
type: array
100100
type: object
101+
x-kubernetes-validations:
102+
- message: storageQuotaInGiB cannot be decreased on update
103+
rule: self.storageQuotaInGiB >= oldSelf.storageQuotaInGiB
101104
status:
102105
description: StorageConsumerStatus defines the observed state of StorageConsumer
103106
properties:

deploy/csv-templates/crds/ocs/ocs.openshift.io_storageconsumers.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ spec:
9898
type: object
9999
type: array
100100
type: object
101+
x-kubernetes-validations:
102+
- message: storageQuotaInGiB cannot be decreased on update
103+
rule: self.storageQuotaInGiB >= oldSelf.storageQuotaInGiB
101104
status:
102105
description: StorageConsumerStatus defines the observed state of StorageConsumer
103106
properties:

deploy/ocs-operator/manifests/storageconsumer.crd.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ spec:
9898
type: object
9999
type: array
100100
type: object
101+
x-kubernetes-validations:
102+
- message: storageQuotaInGiB cannot be decreased on update
103+
rule: self.storageQuotaInGiB >= oldSelf.storageQuotaInGiB
101104
status:
102105
description: StorageConsumerStatus defines the observed state of StorageConsumer
103106
properties:

metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/storageconsumer_types.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/storageconsumer_types.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)