diff --git a/api/replication.storage/v1alpha1/volumegroupreplication_types.go b/api/replication.storage/v1alpha1/volumegroupreplication_types.go index 8ad2bff70..c92b78b46 100644 --- a/api/replication.storage/v1alpha1/volumegroupreplication_types.go +++ b/api/replication.storage/v1alpha1/volumegroupreplication_types.go @@ -28,9 +28,10 @@ type VolumeGroupReplicationSpec struct { // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupReplicationClassName is immutable" VolumeGroupReplicationClassName string `json:"volumeGroupReplicationClassName"` - // volumeReplicationClassName is the volumeReplicationClass name for VolumeReplication object + // volumeReplicationClassName is the volumeReplicationClass name for the VolumeReplication object + // created for this volumeGroupReplication // +kubebuilder:validation:Required - // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumReplicationClassName is immutable" + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeReplicationClassName is immutable" VolumeReplicationClassName string `json:"volumeReplicationClassName"` // Name of the VolumeReplication object created for this volumeGroupReplication @@ -65,7 +66,7 @@ type VolumeGroupReplicationSpec struct { type VolumeGroupReplicationSource struct { // Selector is a label query over persistent volume claims that are to be // grouped together for replication. - // +optional + // +kubebuilder:validation:Required // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="selector is immutable" Selector *metav1.LabelSelector `json:"selector,omitempty"` } diff --git a/api/replication.storage/v1alpha1/volumegroupreplicationcontent_types.go b/api/replication.storage/v1alpha1/volumegroupreplicationcontent_types.go index fcbb7a95a..3eccb0f0c 100644 --- a/api/replication.storage/v1alpha1/volumegroupreplicationcontent_types.go +++ b/api/replication.storage/v1alpha1/volumegroupreplicationcontent_types.go @@ -27,16 +27,15 @@ type VolumeGroupReplicationContentSpec struct { // VolumeGroupReplicationContent object is bound. // VolumeGroupReplication.Spec.VolumeGroupReplicationContentName field must reference to // this VolumeGroupReplicationContent's name for the bidirectional binding to be valid. - // For a pre-existing VolumeGroupReplicationContent object, name and namespace of the - // VolumeGroupReplication object MUST be provided for binding to happen. - // This field is immutable after creation. - // Required. - // +kubebuilder:validation:XValidation:rule="has(self.name) && has(self.__namespace__)",message="both volumeGroupReplicationRef.name and volumeGroupReplicationRef.namespace must be set" - // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupReplicationRef is immutable" - VolumeGroupReplicationRef corev1.ObjectReference `json:"volumeGroupReplicationRef"` + // For a pre-existing VolumeGroupReplication object, MUST provide an empty/nil value for + // VolumeGroupReplicationRef for the auto-binding to happen. + // +kubebuilder:validation:Optional + // +kubebuilder:validation:XValidation:rule="self != null ? has(self.name) && has(self.__namespace__) && has(self.uid) : true",message="volumeGroupReplicationRef.name, volumeGroupReplicationRef.namespace and volumeGroupReplicationRef.uid must be set if volumeGroupReplicationRef is defined" + VolumeGroupReplicationRef *corev1.ObjectReference `json:"volumeGroupReplicationRef,omitempty"` // VolumeGroupReplicationHandle is a unique id returned by the CSI driver // to identify the VolumeGroupReplication on the storage system. + // +kubebuilder:validation:Optional VolumeGroupReplicationHandle string `json:"volumeGroupReplicationHandle"` // provisioner is the name of the CSI driver used to create the physical @@ -45,17 +44,20 @@ type VolumeGroupReplicationContentSpec struct { // This MUST be the same as the name returned by the CSI GetPluginName() call for // that driver. // Required. + // +kubebuilder:validation:Required Provisioner string `json:"provisioner"` // VolumeGroupReplicationClassName is the name of the VolumeGroupReplicationClass from // which this group replication was (or will be) created. - // +optional + // Required. + // +kubebuilder:validation:Required VolumeGroupReplicationClassName string `json:"volumeGroupReplicationClassName"` - // Source specifies whether the snapshot is (or should be) dynamically provisioned - // or already exists, and just requires a Kubernetes object representation. - // This field is immutable after creation. + // Source specifies whether the volume group is (or should be) dynamically provisioned + // or already exists using the volumes listed here, and just requires a + // Kubernetes object representation. // Required. + // +kubebuilder:validation:Required Source VolumeGroupReplicationContentSource `json:"source"` } @@ -63,12 +65,13 @@ type VolumeGroupReplicationContentSpec struct { type VolumeGroupReplicationContentSource struct { // VolumeHandles is a list of volume handles on the backend to be grouped // and replicated. + // +kubebuilder:validation:Required VolumeHandles []string `json:"volumeHandles"` } // VolumeGroupReplicationContentStatus defines the status of VolumeGroupReplicationContent type VolumeGroupReplicationContentStatus struct { - // PersistentVolumeRefList is the list of of PV for the group replication + // PersistentVolumeRefList is the list of PV for the group replication // The maximum number of allowed PV in the group is 100. // +optional PersistentVolumeRefList []corev1.LocalObjectReference `json:"persistentVolumeRefList,omitempty"` diff --git a/api/replication.storage/v1alpha1/zz_generated.deepcopy.go b/api/replication.storage/v1alpha1/zz_generated.deepcopy.go index 565ae0f63..e97d46cc0 100644 --- a/api/replication.storage/v1alpha1/zz_generated.deepcopy.go +++ b/api/replication.storage/v1alpha1/zz_generated.deepcopy.go @@ -231,7 +231,11 @@ func (in *VolumeGroupReplicationContentSource) DeepCopy() *VolumeGroupReplicatio // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VolumeGroupReplicationContentSpec) DeepCopyInto(out *VolumeGroupReplicationContentSpec) { *out = *in - out.VolumeGroupReplicationRef = in.VolumeGroupReplicationRef + if in.VolumeGroupReplicationRef != nil { + in, out := &in.VolumeGroupReplicationRef, &out.VolumeGroupReplicationRef + *out = new(corev1.ObjectReference) + **out = **in + } in.Source.DeepCopyInto(&out.Source) } diff --git a/config/crd/bases/replication.storage.openshift.io_volumegroupreplicationcontents.yaml b/config/crd/bases/replication.storage.openshift.io_volumegroupreplicationcontents.yaml index 425c651eb..2e3b9d999 100644 --- a/config/crd/bases/replication.storage.openshift.io_volumegroupreplicationcontents.yaml +++ b/config/crd/bases/replication.storage.openshift.io_volumegroupreplicationcontents.yaml @@ -52,9 +52,9 @@ spec: type: string source: description: |- - Source specifies whether the snapshot is (or should be) dynamically provisioned - or already exists, and just requires a Kubernetes object representation. - This field is immutable after creation. + Source specifies whether the volume group is (or should be) dynamically provisioned + or already exists using the volumes listed here, and just requires a + Kubernetes object representation. Required. properties: volumeHandles: @@ -71,6 +71,7 @@ spec: description: |- VolumeGroupReplicationClassName is the name of the VolumeGroupReplicationClass from which this group replication was (or will be) created. + Required. type: string volumeGroupReplicationHandle: description: |- @@ -83,10 +84,8 @@ spec: VolumeGroupReplicationContent object is bound. VolumeGroupReplication.Spec.VolumeGroupReplicationContentName field must reference to this VolumeGroupReplicationContent's name for the bidirectional binding to be valid. - For a pre-existing VolumeGroupReplicationContent object, name and namespace of the - VolumeGroupReplication object MUST be provided for binding to happen. - This field is immutable after creation. - Required. + For a pre-existing VolumeGroupReplication object, MUST provide an empty/nil value for + VolumeGroupReplicationRef for the auto-binding to happen. properties: apiVersion: description: API version of the referent. @@ -129,16 +128,15 @@ spec: type: object x-kubernetes-map-type: atomic x-kubernetes-validations: - - message: both volumeGroupReplicationRef.name and volumeGroupReplicationRef.namespace - must be set - rule: has(self.name) && has(self.__namespace__) - - message: volumeGroupReplicationRef is immutable - rule: self == oldSelf + - message: volumeGroupReplicationRef.name, volumeGroupReplicationRef.namespace + and volumeGroupReplicationRef.uid must be set if volumeGroupReplicationRef + is defined + rule: 'self != null ? has(self.name) && has(self.__namespace__) + && has(self.uid) : true' required: - provisioner - source - - volumeGroupReplicationHandle - - volumeGroupReplicationRef + - volumeGroupReplicationClassName type: object status: description: VolumeGroupReplicationContentStatus defines the status of @@ -146,7 +144,7 @@ spec: properties: persistentVolumeRefList: description: |- - PersistentVolumeRefList is the list of of PV for the group replication + PersistentVolumeRefList is the list of PV for the group replication The maximum number of allowed PV in the group is 100. items: description: |- diff --git a/config/crd/bases/replication.storage.openshift.io_volumegroupreplications.yaml b/config/crd/bases/replication.storage.openshift.io_volumegroupreplications.yaml index 73cc47c9b..d126d2851 100644 --- a/config/crd/bases/replication.storage.openshift.io_volumegroupreplications.yaml +++ b/config/crd/bases/replication.storage.openshift.io_volumegroupreplications.yaml @@ -112,6 +112,8 @@ spec: x-kubernetes-validations: - message: selector is immutable rule: self == oldSelf + required: + - selector type: object x-kubernetes-validations: - message: source is immutable @@ -131,11 +133,12 @@ spec: - message: volumeGroupReplicationContentName is immutable rule: self == oldSelf volumeReplicationClassName: - description: volumeReplicationClassName is the volumeReplicationClass - name for VolumeReplication object + description: |- + volumeReplicationClassName is the volumeReplicationClass name for the VolumeReplication object + created for this volumeGroupReplication type: string x-kubernetes-validations: - - message: volumReplicationClassName is immutable + - message: volumeReplicationClassName is immutable rule: self == oldSelf volumeReplicationName: description: Name of the VolumeReplication object created for this diff --git a/deploy/controller/crds.yaml b/deploy/controller/crds.yaml index dec6ee0af..2f6bf94f7 100644 --- a/deploy/controller/crds.yaml +++ b/deploy/controller/crds.yaml @@ -1414,9 +1414,9 @@ spec: type: string source: description: |- - Source specifies whether the snapshot is (or should be) dynamically provisioned - or already exists, and just requires a Kubernetes object representation. - This field is immutable after creation. + Source specifies whether the volume group is (or should be) dynamically provisioned + or already exists using the volumes listed here, and just requires a + Kubernetes object representation. Required. properties: volumeHandles: @@ -1433,6 +1433,7 @@ spec: description: |- VolumeGroupReplicationClassName is the name of the VolumeGroupReplicationClass from which this group replication was (or will be) created. + Required. type: string volumeGroupReplicationHandle: description: |- @@ -1445,10 +1446,8 @@ spec: VolumeGroupReplicationContent object is bound. VolumeGroupReplication.Spec.VolumeGroupReplicationContentName field must reference to this VolumeGroupReplicationContent's name for the bidirectional binding to be valid. - For a pre-existing VolumeGroupReplicationContent object, name and namespace of the - VolumeGroupReplication object MUST be provided for binding to happen. - This field is immutable after creation. - Required. + For a pre-existing VolumeGroupReplication object, MUST provide an empty/nil value for + VolumeGroupReplicationRef for the auto-binding to happen. properties: apiVersion: description: API version of the referent. @@ -1491,16 +1490,15 @@ spec: type: object x-kubernetes-map-type: atomic x-kubernetes-validations: - - message: both volumeGroupReplicationRef.name and volumeGroupReplicationRef.namespace - must be set - rule: has(self.name) && has(self.__namespace__) - - message: volumeGroupReplicationRef is immutable - rule: self == oldSelf + - message: volumeGroupReplicationRef.name, volumeGroupReplicationRef.namespace + and volumeGroupReplicationRef.uid must be set if volumeGroupReplicationRef + is defined + rule: 'self != null ? has(self.name) && has(self.__namespace__) + && has(self.uid) : true' required: - provisioner - source - - volumeGroupReplicationHandle - - volumeGroupReplicationRef + - volumeGroupReplicationClassName type: object status: description: VolumeGroupReplicationContentStatus defines the status of @@ -1508,7 +1506,7 @@ spec: properties: persistentVolumeRefList: description: |- - PersistentVolumeRefList is the list of of PV for the group replication + PersistentVolumeRefList is the list of PV for the group replication The maximum number of allowed PV in the group is 100. items: description: |- @@ -1647,6 +1645,8 @@ spec: x-kubernetes-validations: - message: selector is immutable rule: self == oldSelf + required: + - selector type: object x-kubernetes-validations: - message: source is immutable @@ -1666,11 +1666,12 @@ spec: - message: volumeGroupReplicationContentName is immutable rule: self == oldSelf volumeReplicationClassName: - description: volumeReplicationClassName is the volumeReplicationClass - name for VolumeReplication object + description: |- + volumeReplicationClassName is the volumeReplicationClass name for the VolumeReplication object + created for this volumeGroupReplication type: string x-kubernetes-validations: - - message: volumReplicationClassName is immutable + - message: volumeReplicationClassName is immutable rule: self == oldSelf volumeReplicationName: description: Name of the VolumeReplication object created for this