Skip to content

Commit

Permalink
Delay temporary PVC creation until scheduled time on fresh deploy
Browse files Browse the repository at this point in the history
For consistency groups, temporary PVCs will now be created at the scheduled time
rather than immediately upon fresh deployment.

Signed-off-by: Benamar Mekhissi <[email protected]>
  • Loading branch information
Benamar Mekhissi authored and ShyamsundarR committed Jan 7, 2025
1 parent ca28628 commit 021c6d7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
18 changes: 9 additions & 9 deletions internal/controller/cephfscg/replicationgroupsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,6 @@ func (m *replicationGroupSourceMachine) Synchronize(ctx context.Context) (mover.
return mover.InProgress(), err
}

m.Logger.Info("Restore PVCs from volume group snapshot")

restoredPVCs, err := m.VolumeGroupHandler.RestoreVolumesFromVolumeGroupSnapshot(ctx, m.ReplicationGroupSource)
if err != nil {
m.Logger.Error(err, "Failed to restore volume group snapshot")

return mover.InProgress(), err
}

m.Logger.Info("Create ReplicationSource for each Restored PVC")
vrgName := m.ReplicationGroupSource.GetLabels()[volsync.VRGOwnerNameLabel]
// Pre-allocated shared secret - DRPC will generate and propagate this secret from hub to clusters
Expand All @@ -141,6 +132,15 @@ func (m *replicationGroupSourceMachine) Synchronize(ctx context.Context) (mover.
return mover.InProgress(), nil
}

m.Logger.Info("Restore PVCs from volume group snapshot")

restoredPVCs, err := m.VolumeGroupHandler.RestoreVolumesFromVolumeGroupSnapshot(ctx, m.ReplicationGroupSource)
if err != nil {
m.Logger.Error(err, "Failed to restore volume group snapshot")

return mover.InProgress(), err
}

replicationSources, err := m.VolumeGroupHandler.CreateOrUpdateReplicationSourceForRestoredPVCs(
ctx, m.ReplicationGroupSource.Status.LastSyncStartTime.String(), restoredPVCs, m.ReplicationGroupSource)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/cephfscg/volumegroupsourcehandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
)

var (
VolumeGroupSnapshotNameFormat = "cephfscg-%s"
RestorePVCinCGNameFormat = "cephfscg-%s"
VolumeGroupSnapshotNameFormat = "vs-cg-%s"
RestorePVCinCGNameFormat = "vs-cg-%s"
SnapshotGroup = "snapshot.storage.k8s.io"
SnapshotGroupKind = "VolumeSnapshot"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/vrg_volrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func (v *VRGInstance) protectPVC(pvc *corev1.PersistentVolumeClaim, log logr.Log
// any further and it can be skipped. The pvc will go away eventually.
func skipPVC(pvc *corev1.PersistentVolumeClaim, log logr.Logger) (bool, string) {
if pvc.Status.Phase != corev1.ClaimBound {
log.Info("Skipping handling of VR as PersistentVolumeClaim is not bound", "pvcPhase", pvc.Status.Phase)
log.Info("Skipping handling of VR as PVC is not bound", "pvcPhase", pvc.Status.Phase)

msg := "PVC not bound yet"
// v.updateProtectedPVCCondition(pvc.Name, VRGConditionReasonProgressing, msg)
Expand All @@ -451,7 +451,7 @@ func skipPVC(pvc *corev1.PersistentVolumeClaim, log logr.Logger) (bool, string)
func isPVCDeletedAndNotProtected(pvc *corev1.PersistentVolumeClaim, log logr.Logger) (bool, string) {
// If PVC deleted but not yet protected with a finalizer, skip it!
if !containsString(pvc.Finalizers, PvcVRFinalizerProtected) && rmnutil.ResourceIsDeleted(pvc) {
log.Info("Skipping PersistentVolumeClaim, as it is marked for deletion and not yet protected")
log.Info("Skipping PVC, as it is marked for deletion and not yet protected")

msg := "Skipping pvc marked for deletion"
// v.updateProtectedPVCCondition(pvc.Name, VRGConditionReasonProgressing, msg)
Expand Down
6 changes: 6 additions & 0 deletions internal/controller/vrg_volsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ func (v *VRGInstance) reconcileVolSyncAsPrimary(finalSyncPrepared *bool) (requeu
}

for _, pvc := range v.volSyncPVCs {
if pvc.Status.Phase != corev1.ClaimBound {
v.log.Info("Skipping PVC - PVC is not Bound.", "name", pvc.GetName())

continue
}

requeuePVC := v.reconcilePVCAsVolSyncPrimary(pvc)
if requeuePVC {
requeue = true
Expand Down

0 comments on commit 021c6d7

Please sign in to comment.