Set the elapsed time in MigrationSummary only when required.
Only if a resources or volumes are getting migrated then set their
respective elapsed times.
@@ -1920,6 +1920,17 @@ func (m *MigrationController) getMigrationSummary(migration *stork_api.Migration
migrationSummary.TotalNumberOfVolumes = totalVolumes
migrationSummary.NumberOfMigratedVolumes = doneVolumes
}
+ elapsedTimeVolume := "NA"
+ if !migration.CreationTimestamp.IsZero() {
+ if migration.Status.Stage == stork_api.MigrationStageApplications {
+ if !migration.Status.VolumeMigrationFinishTimestamp.IsZero() {
+ elapsedTimeVolume = migration.Status.VolumeMigrationFinishTimestamp.Sub(migration.CreationTimestamp.Time).String()
+ }
+ } else {
+ elapsedTimeVolume = time.Since(migration.CreationTimestamp.Time).String()
+ }
+ }
+ migrationSummary.ElapsedTimeForVolumeMigration = elapsedTimeVolume
}
if migration.Spec.IncludeResources == nil || *migration.Spec.IncludeResources {
@@ -1934,21 +1945,7 @@ func (m *MigrationController) getMigrationSummary(migration *stork_api.Migration
migrationSummary.TotalNumberOfResources = totalResources
migrationSummary.NumberOfMigratedResources = doneResources
}
- }
-
- elapsedTimeVolume := ""
- if !migration.CreationTimestamp.IsZero() {
- if migration.Status.Stage == stork_api.MigrationStageApplications {
- if !migration.Status.VolumeMigrationFinishTimestamp.IsZero() {
- elapsedTimeVolume = migration.Status.VolumeMigrationFinishTimestamp.Sub(migration.CreationTimestamp.Time).String()
- }
- } else {
- elapsedTimeVolume = time.Since(migration.CreationTimestamp.Time).String()
- }
- }
- migrationSummary.ElapsedTimeForVolumeMigration = elapsedTimeVolume
-
- elapsedTimeResources := ""
+ elapsedTimeResources := "NA"
if !migration.Status.VolumeMigrationFinishTimestamp.IsZero() {
if migration.Status.Stage == stork_api.MigrationStageFinal {
if !migration.Status.ResourceMigrationFinishTimestamp.IsZero() {
@@ -1958,8 +1955,9 @@ func (m *MigrationController) getMigrationSummary(migration *stork_api.Migration
elapsedTimeResources = time.Since(migration.Status.VolumeMigrationFinishTimestamp.Time).String()
}
}
- migrationSummary.ElapsedTimeForVolumeMigration = elapsedTimeVolume
migrationSummary.ElapsedTimeForResourceMigration = elapsedTimeResources
+ }
+
migrationSummary.TotalBytesMigrated = totalBytes
return migrationSummary
}
