Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/dataset/v1alpha1/dataset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ type DatasetSpec struct {
// mountOptions is the options for mounting the dataset.
MountOptions MountOptions `json:"mountOptions,omitempty"`
// +kubebuilder:validation:Optional
// +kubebuilder:validation:XValidation:rule="self - oldSelf <= 1",message="dataSyncRound can only be incremented by 1"
// +kubebuilder:validation:XValidation:rule="self > 0 && self - oldSelf <= 1",message="dataSyncRound can only be incremented by 1"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The validation rule will cause an error during resource creation if dataSyncRound is set to a value greater than 1. On creation, oldSelf is 0, so self - oldSelf <= 1 becomes self <= 1. This is too restrictive and the rule should only apply the increment check on updates.

Suggested change
// +kubebuilder:validation:XValidation:rule="self > 0 && self - oldSelf <= 1",message="dataSyncRound can only be incremented by 1"
// +kubebuilder:validation:XValidation:rule="self > 0 && (oldSelf == 0 || self - oldSelf <= 1)",message="dataSyncRound can only be incremented by 1"

// +kubebuilder:default=1
// dataSyncRound is the number of data sync rounds to be performed."
DataSyncRound int32 `json:"dataSyncRound,omitempty"`
// +kubebuilder:validation:Optional
Expand Down
18 changes: 8 additions & 10 deletions config/crd/bases/dataset.baizeai.io_datasets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ spec:
description: DatasetSpec defines the desired state of Dataset
properties:
dataSyncRound:
default: 1
description: dataSyncRound is the number of data sync rounds to be
performed."
format: int32
type: integer
x-kubernetes-validations:
- message: dataSyncRound can only be incremented by 1
rule: self - oldSelf <= 1
rule: self > 0 && self - oldSelf <= 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This validation rule will prevent creating a resource with dataSyncRound greater than 1. On creation, oldSelf is 0, which makes the rule self - oldSelf <= 1 equivalent to self <= 1.

                  rule: self > 0 && (oldSelf == 0 || self - oldSelf <= 1)

mountOptions:
description: mountOptions is the options for mounting the dataset.
properties:
Expand Down Expand Up @@ -551,18 +552,15 @@ spec:
persistent volume is being resized.
type: string
status:
description: |-
Status is the status of the condition.
Can be True, False, Unknown.
More info: https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#:~:text=state%20of%20pvc-,conditions.status,-(string)%2C%20required
type: string
type:
description: |-
PersistentVolumeClaimConditionType defines the condition of PV claim.
Valid values are:
- "Resizing", "FileSystemResizePending"

If RecoverVolumeExpansionFailure feature gate is enabled, then following additional values can be expected:
- "ControllerResizeError", "NodeResizeError"

If VolumeAttributesClass feature gate is enabled, then following additional values can be expected:
- "ModifyVolumeError", "ModifyingVolume"
Type is the type of the condition.
More info: https://kubernetes.io/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-claim-v1/#:~:text=set%20to%20%27ResizeStarted%27.-,PersistentVolumeClaimCondition,-contains%20details%20about
type: string
required:
- status
Expand Down
Loading