diff --git a/move2kube/README.md b/move2kube/README.md
index 53b65747..fcfc5a50 100644
--- a/move2kube/README.md
+++ b/move2kube/README.md
@@ -11,6 +11,7 @@ Once the transformation is over, move2kube provides a zip file containing the tr
### Workflow
![m2k.svg](https://raw.githubusercontent.com/parodos-dev/serverless-workflows/main/move2kube/m2k.svg)
+Note that if an error occurs during the migration planning there is no feedback given by the move2kube instance API. To overcome this, we defined a maximum amount of retries (`move2kube_get_plan_max_retries`) to execute while getting the planning before exiting with an error. By default the value is set to 10 and it can be overridden with the environment variable `MOVE2KUBE_GET_PLAN_MAX_RETRIES`.
## Components
The use case has the following components:
1. `m2k`: the `Sonataflow` resource representing the workflow. A matching `Deployment` is created by the sonataflow operator..
@@ -62,4 +63,4 @@ backstage-backstage backstage-backstage-backstage-system.apps.cluster-c68jb.dy
11. Then click on `nextStep`
12. Click on `run` to trigger the execution
13. Once a new transformation has started and is waiting for your input, you will receive a notification with a link to the Q&A
-14. Once you completed the Q&A, the process will continue and the output of the transformation will be saved in your git repository, you will receive a notification to inform you of the completion of the workflow.
\ No newline at end of file
+14. Once you completed the Q&A, the process will continue and the output of the transformation will be saved in your git repository, you will receive a notification to inform you of the completion of the workflow.
diff --git a/move2kube/application.properties b/move2kube/application.properties
index 25fc2962..e5910d34 100644
--- a/move2kube/application.properties
+++ b/move2kube/application.properties
@@ -6,6 +6,7 @@ mp.messaging.incoming.kogito_incoming_stream.method=POST
# This property is used when sending the notification while waiting for Q&A
move2kube_url=${MOVE2KUBE_URL:http://move2kube-svc.default.svc.cluster.local:8080}
+move2kube_get_plan_max_retries=${MOVE2KUBE_GET_PLAN_MAX_RETRIES:10}
# This property is used to send requests to the move2kube instance
quarkus.rest-client.move2kube_yaml.url=${MOVE2KUBE_URL:http://move2kube-svc.default.svc.cluster.local:8080}
# This property is used to send requests to the backstage notification plugin
diff --git a/move2kube/m2k.svg b/move2kube/m2k.svg
index 0cb29528..e8046ae9 100644
--- a/move2kube/m2k.svg
+++ b/move2kube/m2k.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/move2kube/m2k.sw.yml b/move2kube/m2k.sw.yml
index fed8bd77..118c1b36 100644
--- a/move2kube/m2k.sw.yml
+++ b/move2kube/m2k.sw.yml
@@ -34,6 +34,9 @@ functions:
operation: specs/move2kube.yaml#start-transformation
- name: createNotification
operation: notifications#createNotification
+ - name: increasePlanRetries
+ type: expression
+ operation: ".planRetries=.planRetries + 1"
states:
- name: StartPlanning
type: operation
@@ -44,6 +47,11 @@ states:
workspace-id: ".workspaceId"
project-id: ".projectId"
remote-source: "\"git+\" + (.repositoryURL|sub(\"http(s)://?\";\"ssh://\")) + \"@\" + .sourceBranch"
+ transition: InitGetPlanningRetry
+ - name: InitGetPlanningRetry
+ type: inject
+ data:
+ planRetries: 0
transition: GetPlanning
- name: GetPlanning
type: operation
@@ -57,6 +65,12 @@ states:
toStateData: .
sleep:
before: PT2S
+ transition: IncreaseGetPlanningRetry
+ - name: IncreaseGetPlanningRetry
+ type: operation
+ actions:
+ - functionRef:
+ refName: increasePlanRetries
transition: PlanRetrievedCheck
- name: PlanRetrievedCheck
type: switch
@@ -64,6 +78,9 @@ states:
- condition: (has("plan") and .plan != "")
transition:
nextState: StartTransformation
+ - condition: (.planRetries > ($SECRET.move2kube_get_plan_max_retries | tonumber))
+ transition:
+ nextState: GetPlanRetryExceededError
defaultCondition:
transition: GetPlanning
- name: StartTransformation
@@ -129,6 +146,11 @@ states:
data:
exitMessage: '"Error while saving transformation output. If no context, it was due to timeout expiration"'
transition: PrintExitErrorMessage
+ - name: GetPlanRetryExceededError
+ type: inject
+ data:
+ exitMessage: '"Get plan retries exceeded, an error probably occurred, check the move2kube instance logs"'
+ transition: PrintExitErrorMessage
- name: PrintExitErrorMessage
type: parallel
branches:
@@ -138,7 +160,7 @@ states:
functionRef:
refName: systemOut
arguments:
- message: '${"m2k workflow: " + $WORKFLOW.instanceId + " has finalized with error. Exit message: " + .exitMessage + " -- Context: " + .error }'
+ message: '${"m2k workflow: " + $WORKFLOW.instanceId + " has finalized with error. Exit message: " + .exitMessage + " -- Plan retries: " + (.planRetries|tostring) + " -- Context: " + .error }'
- name: createNotification
actions:
- name: createNotification
@@ -147,7 +169,7 @@ states:
refName: createNotification
arguments:
title: '"Move2Kube workflow " + $WORKFLOW.instanceId + " failed"'
- message: '"Move2Kube workflow " + $WORKFLOW.instanceId + " on workspace " + .workspaceId + " and project " + .projectId + " failed with exit message: "+ .exitMessage + "\n\nError: " + .error'
+ message: '"Move2Kube workflow " + $WORKFLOW.instanceId + " on workspace " + .workspaceId + " and project " + .projectId + " failed with exit message: "+ .exitMessage + " -- Plan retries: " + (.planRetries|tostring) + " -- Error: " + .error'
origin: "Move2Kube Workflow"
topic: "Move2Kube Workflow"
end: true