Skip to content

Commit

Permalink
add MantleBackupReconciler.replicateManifests
Browse files Browse the repository at this point in the history
Signed-off-by: Ryotaro Banno <[email protected]>
  • Loading branch information
ushitora-anqou committed Oct 9, 2024
1 parent 67139b7 commit 6d1d1e3
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions internal/controller/mantlebackup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,18 +348,7 @@ func (r *MantleBackupReconciler) Reconcile(ctx context.Context, req ctrl.Request
}

if r.role == RolePrimary {
result, err := r.replicate(ctx, logger, &backup)
if err != nil || result != (ctrl.Result{}) {
return result, err
}
prepareResult, result, err := r.prepareForDataSynchronization(ctx, &backup, r.primarySettings.Client)
if err != nil || result != (ctrl.Result{}) {
return result, err
}
if prepareResult.isSecondaryMantleBackupReadyToUse {
return r.primaryCleanup(ctx, logger, &backup)
}
return r.export(ctx, &backup, r.primarySettings.Client, prepareResult)
return r.replicate(ctx, logger, &backup)
}

return ctrl.Result{}, nil
Expand All @@ -373,6 +362,25 @@ func (r *MantleBackupReconciler) SetupWithManager(mgr ctrl.Manager) error {
}

func (r *MantleBackupReconciler) replicate(
ctx context.Context,
logger *slog.Logger,
backup *mantlev1.MantleBackup,
) (ctrl.Result, error) {
result, err := r.replicateManifests(ctx, logger, backup)
if err != nil || result != (ctrl.Result{}) {
return result, err
}
prepareResult, result, err := r.prepareForDataSynchronization(ctx, backup, r.primarySettings.Client)
if err != nil || result != (ctrl.Result{}) {
return result, err
}
if prepareResult.isSecondaryMantleBackupReadyToUse {
return r.primaryCleanup(ctx, logger, backup)
}
return r.export(ctx, backup, r.primarySettings.Client, prepareResult)
}

func (r *MantleBackupReconciler) replicateManifests(
ctx context.Context,
_ *slog.Logger,
backup *mantlev1.MantleBackup,
Expand Down

0 comments on commit 6d1d1e3

Please sign in to comment.