Skip to content

Commit

Permalink
Fix Negative number for plan/migration status's VMs count
Browse files Browse the repository at this point in the history
On both plan and migration status fields, the number of displayed
migrated VMs within the status' progress bar label is sometimes negative,
i.e.  the value of X within "X out of Y VMs migrated" is sometimes
negative.

This is reproduced when at least one VM failed to migrated.

The reason is that failed VMs is often marked with an error but their completed
value is still set to false since VM's migration was not finished yet. So the
calculation of migrated = completed - error < 0.

Signed-off-by: Sharon Gratch <sgratch@redhat.com>
  • Loading branch information
sgratch committed Sep 5, 2024
1 parent 7e85021 commit 792730b
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ export const getMigrationVmsCounts = (vms: V1beta1PlanStatusMigrationVms[]): Mig
);
const vmsCompleted = vms.filter((vm) => vm?.completed);
const vmsError = vms.filter((vm) => vm?.error);
const success = vmsCompleted.length - vmsError.length - vmsCanceled.length;

return {
completed: vmsCompleted.length,
total: vms.length,
canceled: vmsCanceled.length,
error: vmsError.length,
success: vmsCompleted.length - vmsError.length - vmsCanceled.length,
success: success >= 0 ? success : 0,
};
};

Expand Down

0 comments on commit 792730b

Please sign in to comment.