Skip to content

Commit

Permalink
Merge pull request #525 from RizaFarheen/main
Browse files Browse the repository at this point in the history
Update upgrade-workflow.md
  • Loading branch information
RizaFarheen authored Sep 21, 2023
2 parents 5e1f6e4 + fef5a43 commit dd44b3f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 43 deletions.
89 changes: 52 additions & 37 deletions docs/reference-docs/api/workflow/upgrade-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,26 @@ import TabItem from '@theme/TabItem';

# Upgrade Workflow

This api is used to upgrade running workflow to a newer/older version.
All the tasks that present earlier in the new definition will be marked as skipped.
taskOutput is the map contains output of the tasks that are going to be skipped.
workflowInput is the map if user want to set the input to the workflow that is being upgraded.
The support for this api is in beta.
Upgrade Workflow API upgrades a running workflow to a newer/older version. When the workflow is running, one of the tasks would be currently in the execution state. When this workflow is upgraded using this API, all the tasks in the newer definition before this running task will be marked as skipped.

:::note
This API support is currently available only in the Conductor beta version.
:::

## Input Payload

| Attribute | Description |
|---------------|------------------------------------------------------------------------------------------------------------------------------|
| workflowId | The unique identifier of the workflow to be upgraded. |
| name | Name of the workflow to pick the definition for upgrade. |
| version | Version of the workflow to pick the definition for upgrade. |
| taskOutput | Map of Key and Value for the tasks that are going to be skipped. key is the task reference name and value is the task output |
| workflowInput | Map of Key and Value given as the input to the new workflow execution |
| workflowId | The unique identifier of the workflow to be upgraded. |
| name | Name of the workflow with the latest definition to be upgraded. | |
| version | Version to which the workflow is to be updated. | |
| taskOutput | A map of key and value containing the output of the tasks that will be skipped. Here, the key is the task reference name, and the value is the task output. |
| workflowInput | A map of key and value to be given as the input to the new workflow execution. |

## API Endpoint
```
POST /workflow/{workflowId}/upgrade
```

## Examples

Consider a workflow definition as per below,
<p align="center"><img src="/content/img/upgrade-workflow-old-definition.png" alt="Upgrade workflow old definition" width="33%" height="20%"></img></p>
and the new definition of the workflow is,
<p align="center"><img src="/content/img/upgrade-workflow-new-definition.png" alt="Upgrade workflow new definition" width="33%" height="20%"></img></p>

Now the workflow with version 1 is triggered and currently task_2 is completed but task_4 is in running state,
<p align="center"><img src="/content/img/upgrade-workflow-old-running.png" alt="Upgrade workflow old instance running" width="33%" height="20%"></img></p>

Now when we call upgrade api with following UpgradeWorkflowRequest,
```java
UpgradeWorkflowRequest upgradeWorkflowRequest = new UpgradeWorkflowRequest();
Map<String, Object> output = Map.of("updatedBy" , "upgrade");
upgradeWorkflowRequest.setTaskOutput(Map.of("simple_task3", output,"simple_task1",output));
upgradeWorkflowRequest.setWorkflowInput(Map.of("name", "orkes"));

upgradeWorkflowRequest.setVersion(2);
upgradeWorkflowRequest.setName(workflowName);
```
The workflow state will be changed as below,
<p align="center"><img src="/content/img/upgrade-workflow-new-running.png" alt="Upgrade workflow new instance running" width="33%" height="20%"></img></p>
Also the task that are skipped i.e. simple_task_1 and simple_task_3 will have output as per the map output above.
The workflow input will also get changed as per the workflowInput map.

## Client SDK Methods

<Tabs>
Expand All @@ -66,37 +40,78 @@ void upgradeRunningWorkflow(String workflowId, UpgradeWorkflowRequest upgradeWor
<TabItem value="Golang" label="Golang">

```go
Coming Soon
```

</TabItem>
<TabItem value="Python" label="Python">

```python
Coming Soon
```

</TabItem>
<TabItem value="CSharp" label="CSharp">

```csharp
Coming Soon
```

</TabItem>
<TabItem value="Javascript" label="Javascript">

```javascript
Coming Soon
```

</TabItem>
<TabItem value="Typescript" label="Typescript">

```typescript
Coming Soon
```

</TabItem>
<TabItem value="Clojure" label="Clojure">

```clojure
Coming Soon
```

</TabItem>
</Tabs>
</Tabs>

## Examples

<details><summary>Sample Workflow</summary>
<p>

Consider a workflow definition with version 1 as follows:
<p align="center"><img src="/content/img/upgrade-workflow-old-definition.png" alt="Upgrade workflow old definition" width="33%" height="20%"></img></p>

Now let's run the workflow. Currently **simple_task2** is completed, but **simple_task4** is in a running state:
<p align="center"><img src="/content/img/upgrade-workflow-old-running.png" alt="Upgrade workflow old instance running" width="33%" height="20%"></img></p>

Now, we want to update the workflow to the newer definition with 2 more tasks as follows:
<p align="center"><img src="/content/img/upgrade-workflow-new-definition.png" alt="Upgrade workflow new definition" width="33%" height="20%"></img></p>

Let's call the upgrade API with the following **UpgradeWorkflowRequest**:
```java
UpgradeWorkflowRequest upgradeWorkflowRequest = new UpgradeWorkflowRequest();
Map<String, Object> output = Map.of("updatedBy" , "upgrade");
upgradeWorkflowRequest.setTaskOutput(Map.of("simple_task3", output,"simple_task1",output));
upgradeWorkflowRequest.setWorkflowInput(Map.of("name", "orkes"));

upgradeWorkflowRequest.setVersion(2);
upgradeWorkflowRequest.setName(workflowName);
```

Now, the workflow gets upgraded to the latest version as shown below:

<p align="center"><img src="/content/img/upgrade-workflow-new-running.png" alt="Upgrade workflow new instance running" width="33%" height="20%"></img></p>

All the tasks added above the running **simple_task4** gets skipped here. The tasks **simple_task1** and **simple_task3** will have output as per the taskOutput map above. The workflow input will also get changed as per the workflowInput map.

</p>
</details>

13 changes: 7 additions & 6 deletions docs/reference-docs/system-tasks/update-secret.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import TabItem from '@theme/TabItem';

# Update Secret

Update Secret is used to update value of any secret given the user has permission to update the secret.
A system task to update the value of any secret, given the user has permission to update the secret.

## Definitions

Expand All @@ -29,12 +29,13 @@ Update Secret is used to update value of any secret given the user has permissio

| Attributes | Description |
|-------------|-------------------------|
| secretKey | name of the secret key |
| secretValue | value of the secret key |
| secretKey | Name of the secret key. |
| secretValue | Value of the secret key. |

**Notes**
1. User must have update permission over the secretKey otherwise workflow will be terminated with 403 error.
2. If the secret does not exist by the secretKey, it will be created and the value will be as per the secretValue
:::note Notes
1. The user must have update permission over the secretKey; otherwise, the workflow will be terminated with a 403 error.
2. If the secret does not exist by the secretKey, it will be created, and the value will be as per the secretValue.
3. Only one secret can be updated at a time.
:::


0 comments on commit dd44b3f

Please sign in to comment.