Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry GetPlanning a given amount of time then exit in error #132

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion move2kube/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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..
Expand Down Expand Up @@ -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.
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.
1 change: 1 addition & 0 deletions move2kube/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion move2kube/m2k.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 24 additions & 2 deletions move2kube/m2k.sw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -57,13 +65,22 @@ states:
toStateData: .
sleep:
before: PT2S
transition: IncreaseGetPlanningRetry
- name: IncreaseGetPlanningRetry
type: operation
actions:
- functionRef:
refName: increasePlanRetries
transition: PlanRetrievedCheck
- name: PlanRetrievedCheck
type: switch
dataConditions:
- 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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading