Skip to content

Commit 9d8b330

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

File tree

6 files changed

+17
-0
lines changed

6 files changed

+17
-0
lines changed

api/v1alpha1/storageconsumer_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ type StorageConsumerStatus struct {
104104
}
105105

106106
// ClientStatus is the information pushed from connected storage client
107+
// +kubebuilder:validation:XValidation:rule="!(has(oldSelf.storageQuotaUtilizationRatio) && self.storageQuotaUtilizationRatio < oldSelf.storageQuotaUtilizationRatio)",message="storageQuotaUtilizationRatio cannot be decreased on update"
107108
type ClientStatus struct {
108109
// StorageClient Platform Version
109110
// +optional

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

+4
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ spec:
154154
quota of connected client
155155
type: number
156156
type: object
157+
x-kubernetes-validations:
158+
- message: storageQuotaUtilizationRatio cannot be decreased on update
159+
rule: '!(has(oldSelf.storageQuotaUtilizationRatio) && self.storageQuotaUtilizationRatio
160+
< oldSelf.storageQuotaUtilizationRatio)'
157161
lastHeartbeat:
158162
description: Timestamp of last heartbeat received from consumer
159163
format: date-time

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

+4
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ spec:
154154
quota of connected client
155155
type: number
156156
type: object
157+
x-kubernetes-validations:
158+
- message: storageQuotaUtilizationRatio cannot be decreased on update
159+
rule: '!(has(oldSelf.storageQuotaUtilizationRatio) && self.storageQuotaUtilizationRatio
160+
< oldSelf.storageQuotaUtilizationRatio)'
157161
lastHeartbeat:
158162
description: Timestamp of last heartbeat received from consumer
159163
format: date-time

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

+4
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ spec:
154154
quota of connected client
155155
type: number
156156
type: object
157+
x-kubernetes-validations:
158+
- message: storageQuotaUtilizationRatio cannot be decreased on update
159+
rule: '!(has(oldSelf.storageQuotaUtilizationRatio) && self.storageQuotaUtilizationRatio
160+
< oldSelf.storageQuotaUtilizationRatio)'
157161
lastHeartbeat:
158162
description: Timestamp of last heartbeat received from consumer
159163
format: date-time

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

+2
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

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

0 commit comments

Comments
 (0)