Suspend and Resume
This section introduces how to suspend and resume the workflow in KubeVela.
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.
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
vela workflow suspend my-app
tip
Nothing will happen if you suspend an application that has already finished running workflow, which is in running status.
Apply the following example:
apiVersion: core.oam.dev/v1beta1kind: Applicationmetadata:name: suspend-demonamespace: defaultspec:components:- name: comp1type: webserviceproperties:image: crccheck/hello-worldport: 8000- name: comp2type: webserviceproperties:image: crccheck/hello-worldport: 8000workflow:steps:- name: apply1type: apply-componentproperties:component: comp1- name: suspendtype: suspend- name: apply2type: apply-componentproperties:component: comp2
Use vela status to check the status of the Application:
vela status suspend-demo
expected output
About:Name: suspend-demoNamespace: defaultCreated at: 2022-06-27 17:36:58 +0800 CSTStatus: workflowSuspendingWorkflow:mode: StepByStepfinished: falseSuspend: trueTerminated: falseSteps- id:yj9h29uv6vname:apply1type:apply-componentphase:succeeded- id:xvmda4he5ename:suspendtype:suspendphase:runningServices:- Name: comp1Cluster: local Namespace: defaultType: webserviceHealthy Ready:1/1No 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.
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:
vela workflow resume suspend-demo
After successfully continuing the workflow, view the status of the app:
vela status suspend-demo
expected output
About:Name: suspend-demoNamespace: defaultCreated at: 2022-06-27 17:36:58 +0800 CSTStatus: runningWorkflow:mode: StepByStepfinished: trueSuspend: falseTerminated: falseSteps- id:yj9h29uv6vname:apply1type:apply-componentphase:succeededmessage:- id:xvmda4he5ename:suspendtype:suspendphase:succeededmessage:- id:66jonaxjefname:apply2type:apply-componentphase:succeededmessage:Services:- Name: comp2Cluster: local Namespace: defaultType: webserviceHealthy Ready:1/1No trait applied- Name: comp1Cluster: local Namespace: defaultType: webserviceHealthy Ready:1/1No trait applied
As you can see, the workflow has continued to execute.
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:
apiVersion: core.oam.dev/v1beta1kind: Applicationmetadata:name: auto-resumenamespace: defaultspec:components:- name: comp1type: webserviceproperties:image: crccheck/hello-worldport: 8000- name: comp2type: webserviceproperties:image: crccheck/hello-worldport: 8000workflow:steps:- name: apply1type: apply-componentproperties:component: comp1- name: suspendtype: suspendproperties:duration: 5s- name: apply2type: apply-componentproperties:component: comp2
Use vela status to check the status of the Application:
vela status auto-resume
expected output
About:Name: auto-resumeNamespace: defaultCreated at: 2022-06-27 17:57:35 +0800 CSTStatus: runningWorkflow:mode: StepByStepfinished: trueSuspend: falseTerminated: falseSteps- id:q5jhm6mgwvname:apply1type:apply-componentphase:succeededmessage:- id:3xgfcp3cujname:suspendtype:suspendphase:succeededmessage:- id:zjux8ud876name:apply2type:apply-componentphase:succeededmessage:Services:- Name: comp2Cluster: local Namespace: defaultType: webserviceHealthy Ready:1/1No trait applied- Name: comp1Cluster: local Namespace: defaultType: webserviceHealthy Ready:1/1No trait applied
As you can see, the suspend step is automatically executed successfully after five seconds, and the workflow is executed successfully.
Last updated on Feb 9, 2023 by dependabot[bot]