Skip to content
Draft
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: 3 additions & 0 deletions api/v1alpha1/replicationgroupsource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ type ReplicationGroupSourceSpec struct {

// +required
VolumeGroupSnapshotSource *metav1.LabelSelector `json:"volumeGroupSnapshotSource,omitempty"`

//+optional
rsSpecs []VolSyncReplicationSourceSpec `json:"rsSpecs,omitempty"`
}

// ReplicationSourceTriggerSpec defines when a volume will be synchronized with
Expand Down
23 changes: 14 additions & 9 deletions api/v1alpha1/volumereplicationgroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ type VolSyncReplicationDestinationSpec struct {
// protectedPVC contains the information about the PVC to be protected by VolSync
//+optional
ProtectedPVC ProtectedPVC `json:"protectedPVC,omitempty"`

//+optional
MoverConfig *MoverConfig `json:"moverConfig,omitempty"`
}

// VolSyncReplicationSourceSpec defines the configuration for the VolSync
Expand All @@ -110,6 +113,8 @@ type VolSyncReplicationSourceSpec struct {
// to the replication destination (RD).
//+optional
RsyncTLS *RsyncTLSConfig `json:"rsyncTLS,omitempty"`
//+optional
MoverConfig *MoverConfig `json:"moverConfig,omitempty"`
}

// VolSynccSpec defines the ReplicationDestination specs for the Secondary VRG, or
Expand All @@ -127,7 +132,7 @@ type VolSyncSpec struct {
Disabled bool `json:"disabled,omitempty"`

//+optional
MoverConfig []MoverConfig `json:"moverConfig,omitempty"`
// MoverConfig []MoverConfig `json:"moverConfig,omitempty"`
}

type MoverConfig struct {
Expand All @@ -143,15 +148,15 @@ type MoverConfig struct {
// Labels that should be added to data mover pods
// These will be in addition to any labels that VolSync may add

// PVCName is a required field and must not be empty
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
PVCName string `json:"pvcName,omitempty"`
// // PVCName is a required field and must not be empty
// // +kubebuilder:validation:Required
// // +kubebuilder:validation:MinLength=1
// PVCName string `json:"pvcName,omitempty"`

// PVCNameSpace is a required field and must not be empty
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
PVCNameSpace string `json:"pvcNamespace,omitempty"`
// // PVCNameSpace is a required field and must not be empty
// // +kubebuilder:validation:Required
// // +kubebuilder:validation:MinLength=1
// PVCNameSpace string `json:"pvcNamespace,omitempty"`
}

// VRGAction which will be either a Failover or Relocate
Expand Down
24 changes: 17 additions & 7 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

718 changes: 474 additions & 244 deletions config/crd/bases/ramendr.openshift.io_drplacementcontrols.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

481 changes: 481 additions & 0 deletions config/crd/bases/ramendr.openshift.io_replicationgroupsources.yaml

Large diffs are not rendered by default.

718 changes: 474 additions & 244 deletions config/crd/bases/ramendr.openshift.io_volumereplicationgroups.yaml

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions internal/controller/cephfscg/cghandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func NewVSCGHandler(
cgHandler.volumeSnapshotClassSelector = instance.Spec.Async.VolumeSnapshotClassSelector
cgHandler.ramenSchedulingInterval = instance.Spec.Async.SchedulingInterval
cgHandler.volumeGroupSnapshotClassSelector = instance.Spec.Async.VolumeGroupSnapshotClassSelector
// cgHandler.moverConfig = instance.Spec.VolSync.MoverConfig

return cgHandler
}
Expand Down Expand Up @@ -93,6 +94,7 @@ type cgHandler struct {
cgName string

logger logr.Logger
// moverConfig []ramendrv1alpha1.MoverConfig
}

func (c *cgHandler) CreateOrUpdateReplicationGroupDestination(
Expand Down Expand Up @@ -152,6 +154,7 @@ func (c *cgHandler) CreateOrUpdateReplicationGroupDestination(
func (c *cgHandler) CreateOrUpdateReplicationGroupSource(
replicationGroupSourceNamespace string,
runFinalSync bool,
// volSyncSpec *ramendrv1alpha1.VolSyncSpec,
) (*ramendrv1alpha1.ReplicationGroupSource, bool, error) {
replicationGroupSourceName := c.cgName

Expand Down Expand Up @@ -277,6 +280,8 @@ func (c *cgHandler) CreateOrUpdateReplicationGroupSource(
rgs.Spec.VolumeGroupSnapshotClassName = volumeGroupSnapshotClassName
rgs.Spec.VolumeGroupSnapshotSource = c.volumeGroupSnapshotSource

// rgs.Spec.rsSpecs = volSyncSpec.RDSpec

return nil
})
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/controller/cephfscg/replicationgroupsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ func (m *replicationGroupSourceMachine) Synchronize(ctx context.Context) (mover.
replicationSources, srcCreatedOrUpdated, err := m.VolumeGroupHandler.CreateOrUpdateReplicationSourceForRestoredPVCs(
ctx, m.ReplicationGroupSource.Status.LastSyncStartTime.String(),
restoredPVCs, m.ReplicationGroupSource, m.Vrg, m.VSHandler.IsSubmarinerEnabled())
// ctx, m.ReplicationGroupSource.Status.LastSyncStartTime.String(), restoredPVCs, m.ReplicationGroupSource,
/*m.VSHandler.MoverConfig*/ //)
if err != nil {
m.Logger.Error(err, "Failed to create replication source")

Expand Down
17 changes: 14 additions & 3 deletions internal/controller/cephfscg/volumegroupsourcehandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type VolumeGroupSourceHandler interface {
owner metav1.Object,
vrg *ramendrv1alpha1.VolumeReplicationGroup,
isSubmarinerEnabled bool,
// moverConfig []ramendrv1alpha1.MoverConfig,
) ([]*corev1.ObjectReference, bool, error)

CheckReplicationSourceForRestoredPVCsCompleted(
Expand Down Expand Up @@ -470,18 +471,19 @@ func (h *volumeGroupSourceHandler) CreateOrUpdateReplicationSourceForRestoredPVC

pvcName := strings.TrimSuffix(restoredPVC.SourcePVCName, util.SuffixForFinalsyncPVC)

replicationSourceNamepspace := h.VolumeGroupSnapshotNamespace
replicationSourceNamespace := h.VolumeGroupSnapshotNamespace
replicationSource := &volsyncv1alpha1.ReplicationSource{
ObjectMeta: metav1.ObjectMeta{
Name: pvcName,
Namespace: replicationSourceNamepspace,
Namespace: replicationSourceNamespace,
},
}

rdService, err := h.resolveRDService(&restoredPVC, vrg, replicationSourceNamepspace, isSubmarinerEnabled, logger)
rdService, err := h.resolveRDService(&restoredPVC, vrg, replicationSourceNamespace, isSubmarinerEnabled, logger)
if err != nil {
return nil, false, err
}
// rdService := getRemoteServiceNameForRDFromPVCName(pvcName, replicationSourceNamespace)

op, err := ctrlutil.CreateOrUpdate(ctx, h.Client, replicationSource, func() error {
if err := ctrl.SetControllerReference(owner, replicationSource, h.Client.Scheme()); err != nil {
Expand All @@ -505,6 +507,15 @@ func (h *volumeGroupSourceHandler) CreateOrUpdateReplicationSourceForRestoredPVC
KeySecret: &h.VolsyncKeySecretName,
Address: &rdService,
}
moverConfigVal := util.GetVRGMoverConfig(pvcName, replicationSourceNamespace, vrg.Spec.VolSync.RSSpec /*, moverConfig*/)
if moverConfigVal != nil {
mc := volsyncv1alpha1.MoverConfig{
MoverSecurityContext: moverConfigVal.MoverSecurityContext,
MoverServiceAccount: moverConfigVal.MoverServiceAccount,
}

replicationSource.Spec.RsyncTLS.MoverConfig = mc
}

return nil
})
Expand Down
11 changes: 6 additions & 5 deletions internal/controller/drplacementcontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -1858,18 +1858,19 @@ func (d *DRPCInstance) updateVRGOptionalFields(vrg, vrgFromView *rmn.VolumeRepli
// VolSync's DataMover requires the PodSecurityContext to be configured in order to successfully synchronize
// data for workloads that have complex Security Context Constraints (SCC) settings.
// Populate ReplicationSource and ReplicationDestination specs with MoverSecurityContext and MoverServiceAccount
if d.instance.Spec.VolSyncSpec != nil && d.drType == DRTypeAsync {
d.updateMoverConfig(vrg)
if d.instance.Spec.VolSyncSpec != nil && d.drType == DRTypeAsync &&
len(d.instance.Spec.VolSyncSpec.RSSpec) > 0 {
d.updateRSSpecMoverConfig(vrg)
}
}

// Checks if MoverConfig exists in the spec
func (d *DRPCInstance) updateMoverConfig(vrg *rmn.VolumeReplicationGroup) {
if len(d.instance.Spec.VolSyncSpec.MoverConfig) == 0 {
func (d *DRPCInstance) updateRSSpecMoverConfig(vrg *rmn.VolumeReplicationGroup) {
if len(d.instance.Spec.VolSyncSpec.RSSpec) == 0 {
return
}

vrg.Spec.VolSync.MoverConfig = append([]rmn.MoverConfig(nil), d.instance.Spec.VolSyncSpec.MoverConfig...)
vrg.Spec.VolSync.RSSpec = append([]rmn.VolSyncReplicationSourceSpec(nil), d.instance.Spec.VolSyncSpec.RSSpec...)
}

func (d *DRPCInstance) ensurePlacement(homeCluster string) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/drplacementcontrolvolsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func (d *DRPCInstance) refreshVRGSecondarySpec(srcCluster, dstCluster string) (*
d.resetRDSpec(srcVRGView, &dstVRG)

if d.instance.Spec.VolSyncSpec != nil {
d.updateMoverConfig(&dstVRG)
d.updateRSSpecMoverConfig(&dstVRG)
}
}

Expand Down
15 changes: 15 additions & 0 deletions internal/controller/util/cephfs_cg.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,18 @@ func GetVolumeSnapshotsOwnedByVolumeGroupSnapshot(

return volumeSnapshots, nil
}

func GetVRGMoverConfig(name, namespace string, /*moverConfigArr []ramendrv1alpha1.MoverConfig,*/
rsSpec []ramendrv1alpha1.VolSyncReplicationSourceSpec,
) *ramendrv1alpha1.MoverConfig {
if len(rsSpec) > 0 {
for _, rs := range rsSpec {
if rs.ProtectedPVC.Name == name &&
rs.ProtectedPVC.Namespace == namespace {
return rs.MoverConfig
}
}
}

return nil
}
7 changes: 7 additions & 0 deletions internal/controller/volsync/vshandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type VSHandler struct {
volumeSnapshotClassList *snapv1.VolumeSnapshotClassList
vrgInAdminNamespace bool
workloadStatus string
moverConfig []ramendrv1alpha1.MoverConfig
}

func NewVSHandler(ctx context.Context, client client.Client, log logr.Logger, owner metav1.Object,
Expand All @@ -105,6 +106,12 @@ func NewVSHandler(ctx context.Context, client client.Client, log logr.Logger, ow
vsHandler.volumeSnapshotClassSelector = asyncSpec.VolumeSnapshotClassSelector
}

vrg, ok := owner.(*ramendrv1alpha1.VolumeReplicationGroup)
if !ok {
log.Info("VolumeReplicationGroup(PVC) map function received non-VRG resource")
}
vsHandler.moverConfig = vrg.Spec.VolSync.MoverConfig

return vsHandler
}

Expand Down
10 changes: 5 additions & 5 deletions internal/controller/vrg_volsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,11 @@ func (v *VRGInstance) reconcileRDSpecForDeletionOrReplication() bool {
}

func (v *VRGInstance) GetVRGMoverConfig(name, namespace string) *ramendrv1alpha1.MoverConfig {
if len(v.instance.Spec.VolSync.MoverConfig) > 0 {
for _, moverConfig := range v.instance.Spec.VolSync.MoverConfig {
if moverConfig.PVCName == name &&
moverConfig.PVCNameSpace == namespace {
return &moverConfig
if len(v.instance.Spec.VolSync.RSSpec) > 0 {
for _, rsSpec := range v.instance.Spec.VolSync.RSSpec {
if rsSpec.ProtectedPVC.Name == name &&
rsSpec.ProtectedPVC.Namespace == namespace {
return rsSpec.MoverConfig
}
}
}
Expand Down