From a87fa073b8fda3458e1a05eca95297c1d7dad558 Mon Sep 17 00:00:00 2001 From: rakeshgm Date: Tue, 21 May 2024 18:45:36 +0530 Subject: [PATCH 1/2] extend DRPolicy and VRG spec with PeerClasses Signed-off-by: rakeshgm (cherry picked from commit 57174af67b877848a7082fc39c86c7f8ba42d202) --- api/v1alpha1/drpolicy_types.go | 16 ++++ api/v1alpha1/volumereplicationgroup_types.go | 19 +++- api/v1alpha1/zz_generated.deepcopy.go | 95 ++++++++++++++++++- .../ramendr.openshift.io_drpolicies.yaml | 34 +++++++ ..._protectedvolumereplicationgrouplists.yaml | 27 ++++++ ....openshift.io_volumereplicationgroups.yaml | 27 ++++++ 6 files changed, 216 insertions(+), 2 deletions(-) diff --git a/api/v1alpha1/drpolicy_types.go b/api/v1alpha1/drpolicy_types.go index 3685b8101..15de54a86 100644 --- a/api/v1alpha1/drpolicy_types.go +++ b/api/v1alpha1/drpolicy_types.go @@ -48,6 +48,22 @@ type DRPolicySpec struct { // DRPolicyStatus defines the observed state of DRPolicy type DRPolicyStatus struct { Conditions []metav1.Condition `json:"conditions,omitempty"` + //+optional + Async *AsyncSpec `json:"async,omitempty"` + //+optional + Sync *SyncSpec `json:"sync,omitempty"` +} + +// for RDR +type AsyncSpec struct { + //+optional + PeerClasses []PeerClass `json:"peerClasses,omitempty"` +} + +// for MetroDR +type SyncSpec struct { + //+optional + PeerClasses []PeerClass `json:"peerClasses,omitempty"` } const ( diff --git a/api/v1alpha1/volumereplicationgroup_types.go b/api/v1alpha1/volumereplicationgroup_types.go index 18d27c705..ea6c0b4cc 100644 --- a/api/v1alpha1/volumereplicationgroup_types.go +++ b/api/v1alpha1/volumereplicationgroup_types.go @@ -56,10 +56,16 @@ type VRGAsyncSpec struct { // +kubebuilder:validation:Required // +kubebuilder:validation:Pattern=`^\d+[mhd]$` SchedulingInterval string `json:"schedulingInterval"` + + //+optional + PeerClasses []PeerClass `json:"peerClasses,omitempty"` } // VRGSyncSpec has the parameters associated with MetroDR -type VRGSyncSpec struct{} +type VRGSyncSpec struct { + //+optional + PeerClasses []PeerClass `json:"peerClasses,omitempty"` +} // VolSyncReplicationDestinationSpec defines the configuration for the VolSync // protected PVC to be used by the destination cluster (Secondary) @@ -69,6 +75,17 @@ type VolSyncReplicationDestinationSpec struct { ProtectedPVC ProtectedPVC `json:"protectedPVC,omitempty"` } +type PeerClass struct { + //+optional + ReplicationID string `json:"replicationID,omitempty"` + + //+optional + StorageID []string `json:"storageID,omitempty"` + + //+optional + StorageClassName *string `json:"storageClassName,omitempty"` +} + // VolSyncReplicationSourceSpec defines the configuration for the VolSync // protected PVC to be used by the source cluster (Primary) type VolSyncReplicationSourceSpec struct { diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 0fede41a4..c84826d5d 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -13,6 +13,28 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AsyncSpec) DeepCopyInto(out *AsyncSpec) { + *out = *in + if in.PeerClasses != nil { + in, out := &in.PeerClasses, &out.PeerClasses + *out = make([]PeerClass, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AsyncSpec. +func (in *AsyncSpec) DeepCopy() *AsyncSpec { + if in == nil { + return nil + } + out := new(AsyncSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterMaintenanceMode) DeepCopyInto(out *ClusterMaintenanceMode) { *out = *in @@ -380,6 +402,16 @@ func (in *DRPolicyStatus) DeepCopyInto(out *DRPolicyStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.Async != nil { + in, out := &in.Async, &out.Async + *out = new(AsyncSpec) + (*in).DeepCopyInto(*out) + } + if in.Sync != nil { + in, out := &in.Sync, &out.Sync + *out = new(SyncSpec) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DRPolicyStatus. @@ -596,6 +628,31 @@ func (in *MaintenanceModeStatus) DeepCopy() *MaintenanceModeStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PeerClass) DeepCopyInto(out *PeerClass) { + *out = *in + if in.StorageID != nil { + in, out := &in.StorageID, &out.StorageID + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.StorageClassName != nil { + in, out := &in.StorageClassName, &out.StorageClassName + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PeerClass. +func (in *PeerClass) DeepCopy() *PeerClass { + if in == nil { + return nil + } + out := new(PeerClass) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PlacementDecision) DeepCopyInto(out *PlacementDecision) { *out = *in @@ -868,11 +925,40 @@ func (in *StorageIdentifiers) DeepCopy() *StorageIdentifiers { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SyncSpec) DeepCopyInto(out *SyncSpec) { + *out = *in + if in.PeerClasses != nil { + in, out := &in.PeerClasses, &out.PeerClasses + *out = make([]PeerClass, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SyncSpec. +func (in *SyncSpec) DeepCopy() *SyncSpec { + if in == nil { + return nil + } + out := new(SyncSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VRGAsyncSpec) DeepCopyInto(out *VRGAsyncSpec) { *out = *in in.ReplicationClassSelector.DeepCopyInto(&out.ReplicationClassSelector) in.VolumeSnapshotClassSelector.DeepCopyInto(&out.VolumeSnapshotClassSelector) + if in.PeerClasses != nil { + in, out := &in.PeerClasses, &out.PeerClasses + *out = make([]PeerClass, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VRGAsyncSpec. @@ -931,6 +1017,13 @@ func (in *VRGResourceMeta) DeepCopy() *VRGResourceMeta { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VRGSyncSpec) DeepCopyInto(out *VRGSyncSpec) { *out = *in + if in.PeerClasses != nil { + in, out := &in.PeerClasses, &out.PeerClasses + *out = make([]PeerClass, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VRGSyncSpec. @@ -1073,7 +1166,7 @@ func (in *VolumeReplicationGroupSpec) DeepCopyInto(out *VolumeReplicationGroupSp if in.Sync != nil { in, out := &in.Sync, &out.Sync *out = new(VRGSyncSpec) - **out = **in + (*in).DeepCopyInto(*out) } in.VolSync.DeepCopyInto(&out.VolSync) if in.KubeObjectProtection != nil { diff --git a/config/crd/bases/ramendr.openshift.io_drpolicies.yaml b/config/crd/bases/ramendr.openshift.io_drpolicies.yaml index 43d557a87..a8bd4bb03 100644 --- a/config/crd/bases/ramendr.openshift.io_drpolicies.yaml +++ b/config/crd/bases/ramendr.openshift.io_drpolicies.yaml @@ -175,6 +175,23 @@ spec: status: description: DRPolicyStatus defines the observed state of DRPolicy properties: + async: + description: for RDR + properties: + peerClasses: + items: + properties: + replicationID: + type: string + storageClassName: + type: string + storageID: + items: + type: string + type: array + type: object + type: array + type: object conditions: items: description: "Condition contains details for one aspect of the current @@ -244,6 +261,23 @@ spec: - type type: object type: array + sync: + description: for MetroDR + properties: + peerClasses: + items: + properties: + replicationID: + type: string + storageClassName: + type: string + storageID: + items: + type: string + type: array + type: object + type: array + type: object type: object type: object served: true diff --git a/config/crd/bases/ramendr.openshift.io_protectedvolumereplicationgrouplists.yaml b/config/crd/bases/ramendr.openshift.io_protectedvolumereplicationgrouplists.yaml index 4e2c0b7be..40b1ce283 100644 --- a/config/crd/bases/ramendr.openshift.io_protectedvolumereplicationgrouplists.yaml +++ b/config/crd/bases/ramendr.openshift.io_protectedvolumereplicationgrouplists.yaml @@ -120,6 +120,19 @@ spec: description: VRGAsyncSpec has the parameters associated with RegionalDR properties: + peerClasses: + items: + properties: + replicationID: + type: string + storageClassName: + type: string + storageID: + items: + type: string + type: array + type: object + type: array replicationClassSelector: description: |- Label selector to identify the VolumeReplicationClass resources @@ -376,6 +389,20 @@ spec: sync: description: VRGSyncSpec has the parameters associated with MetroDR + properties: + peerClasses: + items: + properties: + replicationID: + type: string + storageClassName: + type: string + storageID: + items: + type: string + type: array + type: object + type: array type: object volSync: description: volsync defines the configuration when using diff --git a/config/crd/bases/ramendr.openshift.io_volumereplicationgroups.yaml b/config/crd/bases/ramendr.openshift.io_volumereplicationgroups.yaml index 57677cce1..1d30d07d2 100644 --- a/config/crd/bases/ramendr.openshift.io_volumereplicationgroups.yaml +++ b/config/crd/bases/ramendr.openshift.io_volumereplicationgroups.yaml @@ -70,6 +70,19 @@ spec: async: description: VRGAsyncSpec has the parameters associated with RegionalDR properties: + peerClasses: + items: + properties: + replicationID: + type: string + storageClassName: + type: string + storageID: + items: + type: string + type: array + type: object + type: array replicationClassSelector: description: |- Label selector to identify the VolumeReplicationClass resources @@ -325,6 +338,20 @@ spec: type: array sync: description: VRGSyncSpec has the parameters associated with MetroDR + properties: + peerClasses: + items: + properties: + replicationID: + type: string + storageClassName: + type: string + storageID: + items: + type: string + type: array + type: object + type: array type: object volSync: description: volsync defines the configuration when using VolSync From a4c7bb5b338164c226d9f3872397bf70aa2999fe Mon Sep 17 00:00:00 2001 From: rakeshgm Date: Wed, 12 Jun 2024 19:11:07 +0530 Subject: [PATCH 2/2] add peerClasses to VRG from DRPolicy introduced PeerClasses field under spec.Async and spec.Sync. this contains replciation id, storage id and StorageClassName. Signed-off-by: rakeshgm (cherry picked from commit 6b132c5495989bfb96b8f8b9925bc72992d153cc) --- api/v1alpha1/drpolicy_types.go | 4 ++-- api/v1alpha1/volumereplicationgroup_types.go | 2 +- api/v1alpha1/zz_generated.deepcopy.go | 17 ++--------------- internal/controller/drplacementcontrol.go | 5 ++++- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/api/v1alpha1/drpolicy_types.go b/api/v1alpha1/drpolicy_types.go index 15de54a86..cc231895e 100644 --- a/api/v1alpha1/drpolicy_types.go +++ b/api/v1alpha1/drpolicy_types.go @@ -49,9 +49,9 @@ type DRPolicySpec struct { type DRPolicyStatus struct { Conditions []metav1.Condition `json:"conditions,omitempty"` //+optional - Async *AsyncSpec `json:"async,omitempty"` + Async AsyncSpec `json:"async,omitempty"` //+optional - Sync *SyncSpec `json:"sync,omitempty"` + Sync SyncSpec `json:"sync,omitempty"` } // for RDR diff --git a/api/v1alpha1/volumereplicationgroup_types.go b/api/v1alpha1/volumereplicationgroup_types.go index ea6c0b4cc..89e5f1f84 100644 --- a/api/v1alpha1/volumereplicationgroup_types.go +++ b/api/v1alpha1/volumereplicationgroup_types.go @@ -83,7 +83,7 @@ type PeerClass struct { StorageID []string `json:"storageID,omitempty"` //+optional - StorageClassName *string `json:"storageClassName,omitempty"` + StorageClassName string `json:"storageClassName,omitempty"` } // VolSyncReplicationSourceSpec defines the configuration for the VolSync diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index c84826d5d..3dbbe8333 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -402,16 +402,8 @@ func (in *DRPolicyStatus) DeepCopyInto(out *DRPolicyStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.Async != nil { - in, out := &in.Async, &out.Async - *out = new(AsyncSpec) - (*in).DeepCopyInto(*out) - } - if in.Sync != nil { - in, out := &in.Sync, &out.Sync - *out = new(SyncSpec) - (*in).DeepCopyInto(*out) - } + in.Async.DeepCopyInto(&out.Async) + in.Sync.DeepCopyInto(&out.Sync) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DRPolicyStatus. @@ -636,11 +628,6 @@ func (in *PeerClass) DeepCopyInto(out *PeerClass) { *out = make([]string, len(*in)) copy(*out, *in) } - if in.StorageClassName != nil { - in, out := &in.StorageClassName, &out.StorageClassName - *out = new(string) - **out = **in - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PeerClass. diff --git a/internal/controller/drplacementcontrol.go b/internal/controller/drplacementcontrol.go index 116d15e2e..8513f9dca 100644 --- a/internal/controller/drplacementcontrol.go +++ b/internal/controller/drplacementcontrol.go @@ -1614,6 +1614,7 @@ func (d *DRPCInstance) generateVRGSpecAsync() *rmn.VRGAsyncSpec { ReplicationClassSelector: d.drPolicy.Spec.ReplicationClassSelector, VolumeSnapshotClassSelector: d.drPolicy.Spec.VolumeSnapshotClassSelector, SchedulingInterval: d.drPolicy.Spec.SchedulingInterval, + PeerClasses: d.drPolicy.Status.Async.PeerClasses, } } @@ -1622,7 +1623,9 @@ func (d *DRPCInstance) generateVRGSpecAsync() *rmn.VRGAsyncSpec { func (d *DRPCInstance) generateVRGSpecSync() *rmn.VRGSyncSpec { if d.drType == DRTypeSync { - return &rmn.VRGSyncSpec{} + return &rmn.VRGSyncSpec{ + PeerClasses: d.drPolicy.Status.Async.PeerClasses, + } } return nil