Skip to content

Handle pause and resume action of workflow

Halil Coban requested to merge support-pause-and-resume-events into master

What does this MR do and why?

We now handle pause and resume status actions to update workflow status.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. Create a personal access token with api and ai_features scope
  2. Run gdk with ultimate license and allow duo features and experiment features in namespace settings
  3. For a project within a namespace mentioned in the above point, create a workflow and note the workflow_id in the response
curl POST --verbose \
    --header "Authorization: Bearer [YOUR_TOKEN]" \
    --header 'Content-Type: application/json' \
    --data '{
        "project_id": "[your_namespace/your_project]", "goal": "My goal"
    }' \
    http://gdk.test:3000/api/v4/ai/duo_workflows/workflows
  1. The workflow should have a created status. Try to pause it, it should fail
curl --request PATCH --verbose \
    --header "Authorization: Bearer [YOUR_TOKEN]" \
    --header 'Content-Type: application/json' \
    --data '{"status_event": "pause" }' http://gdk.test:3000/api/v4/ai/duo_workflows/workflows/[workflow_id_from_response]

It should fail with {"message":"Can not pause workflow that has status created"}

  1. At first, start the workflow so that it can be paused
curl --request PATCH --verbose \
    --header "Authorization: Bearer [YOUR_TOKEN]" \
    --header 'Content-Type: application/json' \
    --data '{"status_event": "start" }' http://gdk.test:3000/api/v4/ai/duo_workflows/workflows/[workflow_id_from_response]
  1. Now try to pause it
curl --request PATCH --verbose \
    --header "Authorization: Bearer [YOUR_TOKEN]" \
    --header 'Content-Type: application/json' \
    --data '{"status_event": "pause" }' http://gdk.test:3000/api/v4/ai/duo_workflows/workflows/[workflow_id_from_response]

Request should succeed. You can check the status enum in the response. It must be 2 which means paused.

  1. Now try to resume
curl --request PATCH --verbose \
    --header "Authorization: Bearer [YOUR_TOKEN]" \
    --header 'Content-Type: application/json' \
    --data '{"status_event": "resume" }' http://gdk.test:3000/api/v4/ai/duo_workflows/workflows/[workflow_id_from_response]

Request should succeed. You can check the status enum in the response. It must be 1 which means running.

Resolves: #499891 (closed)

Edited by Halil Coban

Merge request reports

Loading