Suspend and Resume

This section introduces how to suspend and resume the workflow in KubeVela.

Suspend the Workflow

In KubeVela, you can choose to use the vela command to manually suspend the execution of the workflow, or use a built-in special step type suspend to automatically suspend the workflow.

Suspend Manually

If you have an application in runningWorkflow state, you want to stop the execution of the workflow, you can use vela workflow suspend to stop the workflow and use vela workflow resume to continue it.

  • Suspend the application
  1. vela workflow suspend my-app

Suspend and Resume - 图1tip

Nothing will happen if you suspend an application that has already finished running workflow, which is in running status.

Use Suspend Step

Apply the following example:

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: suspend-demo
  5. namespace: default
  6. spec:
  7. components:
  8. - name: comp1
  9. type: webservice
  10. properties:
  11. image: crccheck/hello-world
  12. port: 8000
  13. - name: comp2
  14. type: webservice
  15. properties:
  16. image: crccheck/hello-world
  17. port: 8000
  18. workflow:
  19. steps:
  20. - name: apply1
  21. type: apply-component
  22. properties:
  23. component: comp1
  24. - name: suspend
  25. type: suspend
  26. - name: apply2
  27. type: apply-component
  28. properties:
  29. component: comp2

Use vela status to check the status of the Application:

  1. vela status suspend-demo

expected output

  1. About:
  2. Name: suspend-demo
  3. Namespace: default
  4. Created at: 2022-06-27 17:36:58 +0800 CST
  5. Status: workflowSuspending
  6. Workflow:
  7. mode: StepByStep
  8. finished: false
  9. Suspend: true
  10. Terminated: false
  11. Steps
  12. - id:yj9h29uv6v
  13. name:apply1
  14. type:apply-component
  15. phase:succeeded
  16. - id:xvmda4he5e
  17. name:suspend
  18. type:suspend
  19. phase:running
  20. Services:
  21. - Name: comp1
  22. Cluster: local Namespace: default
  23. Type: webservice
  24. Healthy Ready:1/1
  25. No trait applied

As you can see, when the first step is completed, the suspend step will be executed and this step will suspend the workflow.

Resume the Workflow

Resume Manually

Once the workflow is suspended, you can use the vela workflow resume command to manually resume the workflow.

Take the above suspended application as an example:

  1. vela workflow resume suspend-demo

After successfully continuing the workflow, view the status of the app:

  1. vela status suspend-demo

expected output

  1. About:
  2. Name: suspend-demo
  3. Namespace: default
  4. Created at: 2022-06-27 17:36:58 +0800 CST
  5. Status: running
  6. Workflow:
  7. mode: StepByStep
  8. finished: true
  9. Suspend: false
  10. Terminated: false
  11. Steps
  12. - id:yj9h29uv6v
  13. name:apply1
  14. type:apply-component
  15. phase:succeeded
  16. message:
  17. - id:xvmda4he5e
  18. name:suspend
  19. type:suspend
  20. phase:succeeded
  21. message:
  22. - id:66jonaxjef
  23. name:apply2
  24. type:apply-component
  25. phase:succeeded
  26. message:
  27. Services:
  28. - Name: comp2
  29. Cluster: local Namespace: default
  30. Type: webservice
  31. Healthy Ready:1/1
  32. No trait applied
  33. - Name: comp1
  34. Cluster: local Namespace: default
  35. Type: webservice
  36. Healthy Ready:1/1
  37. No trait applied

As you can see, the workflow has continued to execute.

Resume the Workflow Automatically

If you want the workflow to be continued automatically after a period of time has passed. Then, you can add a duration parameter to the suspend step. When the duration time elapses, the workflow will automatically continue execution.

Apply the following example:

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: auto-resume
  5. namespace: default
  6. spec:
  7. components:
  8. - name: comp1
  9. type: webservice
  10. properties:
  11. image: crccheck/hello-world
  12. port: 8000
  13. - name: comp2
  14. type: webservice
  15. properties:
  16. image: crccheck/hello-world
  17. port: 8000
  18. workflow:
  19. steps:
  20. - name: apply1
  21. type: apply-component
  22. properties:
  23. component: comp1
  24. - name: suspend
  25. type: suspend
  26. properties:
  27. duration: 5s
  28. - name: apply2
  29. type: apply-component
  30. properties:
  31. component: comp2

Use vela status to check the status of the Application:

  1. vela status auto-resume

expected output

  1. About:
  2. Name: auto-resume
  3. Namespace: default
  4. Created at: 2022-06-27 17:57:35 +0800 CST
  5. Status: running
  6. Workflow:
  7. mode: StepByStep
  8. finished: true
  9. Suspend: false
  10. Terminated: false
  11. Steps
  12. - id:q5jhm6mgwv
  13. name:apply1
  14. type:apply-component
  15. phase:succeeded
  16. message:
  17. - id:3xgfcp3cuj
  18. name:suspend
  19. type:suspend
  20. phase:succeeded
  21. message:
  22. - id:zjux8ud876
  23. name:apply2
  24. type:apply-component
  25. phase:succeeded
  26. message:
  27. Services:
  28. - Name: comp2
  29. Cluster: local Namespace: default
  30. Type: webservice
  31. Healthy Ready:1/1
  32. No trait applied
  33. - Name: comp1
  34. Cluster: local Namespace: default
  35. Type: webservice
  36. Healthy Ready:1/1
  37. No trait applied

As you can see, the suspend step is automatically executed successfully after five seconds, and the workflow is executed successfully.