-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If a migration task isn't completed but the migration is successful, …
…mark task as successful, Reference: #1305 In case a migraiton task is not marked as finished (i.e. task.phase is undefined), but its pipeline step is marked as completed succesfully then mark the task as completed succesfully as well. Signed-off-by: Sharon Gratch <sgratch@redhat.com>
- Loading branch information
Showing
4 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...es/forklift-console-plugin/src/modules/Plans/views/details/utils/hasPipelineCompleted.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { V1beta1PlanStatusMigrationVmsPipeline } from '@kubev2v/types'; | ||
|
||
/** | ||
* Check if a given migration's pipeline step has completed successfully. | ||
* | ||
* @param {V1beta1PlanStatusMigrationVmsPipeline} pipeline - A given migration's pipeline step | ||
* @returns {boolean} - True if the migration step has completed successfully, false otherwise. | ||
*/ | ||
const hasPipelineCompleted = (pipeline: V1beta1PlanStatusMigrationVmsPipeline) => { | ||
if (pipeline?.error) { | ||
return false; | ||
} | ||
|
||
switch (pipeline?.phase) { | ||
case 'Completed': | ||
return true; | ||
case 'Pending': | ||
case 'Running': | ||
default: | ||
return false; | ||
} | ||
}; | ||
|
||
/** | ||
* Check if the task isn't marked as finished, but its contained pipeline step has completed successfully. | ||
* | ||
* @param {string } taskPhase A given task phase | ||
* @param {V1beta1PlanStatusMigrationVmsPipeline} pipeline - A given migration's pipeline step which includes the task | ||
* @returns {boolean} - Returns True if the task isn't marked as finished, but its contained pipeline step has completed successfully. | ||
*/ | ||
export const isTaskCompletedByItsPipeline = ( | ||
taskPhase: string, | ||
pipeline: V1beta1PlanStatusMigrationVmsPipeline, | ||
) => taskPhase === undefined && hasPipelineCompleted(pipeline); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters