Skip to content

Commit

Permalink
Skip volume migration rollback for non storage conversion (#1388)
Browse files Browse the repository at this point in the history
Only do a rollback if we are doing a direct storage
conversion. Any other type of migration don't sync
the data back to the source.

Fixed two other issues:
- NPE when a source cluster is not found
- On a live migration rollback, the skipped volumes
where appended endlessly instead of resetting the
skipped list everything reconcile.

Signed-off-by: Alexander Wels <[email protected]>
  • Loading branch information
awels authored Aug 30, 2024
1 parent 5a8450b commit 783f54c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ func (r *ReconcileDirectVolumeMigration) cleanupTargetResourcesInNamespaces(dire
if err != nil {
return false, err
}
if destinationCluster == nil {
return false, nil
}

// Cleanup source resources
client, err := destinationCluster.GetClient(r)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/directvolumemigration/rsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,7 @@ func (t *Task) hasAllProgressReportingCompleted() (bool, error) {
if err := t.populateVMMappings(ns); err != nil {
return false, err
}
t.Owner.Status.SkippedVolumes = []string{}
for _, vol := range vols {
matchString := fmt.Sprintf("%s/%s", ns, vol.Name)
if t.PlanResources.MigPlan.LiveMigrationChecked() &&
Expand All @@ -1420,7 +1421,6 @@ func (t *Task) hasAllProgressReportingCompleted() (bool, error) {
}
}
}

return t.Owner.AllReportingCompleted(), nil
}

Expand Down
12 changes: 10 additions & 2 deletions pkg/controller/migmigration/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const (
HasPreRestoreHooks = 0x4000 // True when postbackup hooks exist
HasPostRestoreHooks = 0x8000 // True when postbackup hooks exist
StorageConversion = 0x10000 // True when the migration is a storage conversion
LiveVmMigration = 0x20000 // True when the migration is a live vm migration
)

// Migration steps
Expand Down Expand Up @@ -299,8 +300,8 @@ var RollbackItinerary = Itinerary{
{Name: QuiesceDestinationApplications, Step: StepCleanupMigrated, all: DirectVolume | EnableVolume},
{Name: EnsureDestQuiesced, Step: StepCleanupMigrated, all: DirectVolume | EnableVolume},
{Name: SwapPVCReferences, Step: StepCleanupMigrated, all: StorageConversion},
{Name: CreateDirectVolumeMigrationRollback, Step: StepRollbackLiveMigration, all: DirectVolume | EnableVolume},
{Name: WaitForDirectVolumeMigrationRollbackToComplete, Step: StepRollbackLiveMigration, all: DirectVolume | EnableVolume},
{Name: CreateDirectVolumeMigrationRollback, Step: StepRollbackLiveMigration, all: DirectVolume | EnableVolume | LiveVmMigration},
{Name: WaitForDirectVolumeMigrationRollbackToComplete, Step: StepRollbackLiveMigration, all: DirectVolume | EnableVolume | LiveVmMigration},
{Name: DeleteMigrated, Step: StepCleanupMigrated},
{Name: EnsureMigratedDeleted, Step: StepCleanupMigrated},
{Name: UnQuiesceSrcApplications, Step: StepCleanupUnquiesce},
Expand Down Expand Up @@ -1387,6 +1388,9 @@ func (t *Task) allFlags(phase Phase) (bool, error) {
if phase.all&IndirectImage != 0 && !t.indirectImageMigration() {
return false, nil
}
if phase.all&LiveVmMigration != 0 && !t.liveVolumeMigration() {
return false, nil
}
if phase.all&EnableImage != 0 && t.PlanResources.MigPlan.IsImageMigrationDisabled() {
return false, nil
}
Expand Down Expand Up @@ -1773,6 +1777,10 @@ func (t *Task) directVolumeMigration() bool {
return !t.indirectVolumeMigration() && t.hasDirectVolumes()
}

func (t *Task) liveVolumeMigration() bool {
return t.PlanResources.MigPlan.Spec.LiveMigrate != nil && *t.PlanResources.MigPlan.Spec.LiveMigrate
}

// Returns true if the migration requires a stage backup
func (t *Task) hasStageBackup(hasIS, anyPVs, moveSnapshotPVs bool) bool {
return hasIS && t.indirectImageMigration() || anyPVs && t.indirectVolumeMigration() || moveSnapshotPVs
Expand Down

0 comments on commit 783f54c

Please sign in to comment.