# Workflow Execution

Source: https://docs.ops0.com/docs/workflows/execution

Monitor running workflows, view real-time logs, handle approvals, and manage failures.

## Execution View

DAG Progress

Visual step progress with status icons

Step List

All steps with duration and actions

Log Panel

Real-time streaming output

Header

Status, duration, trigger info

---

## Step Status

| Icon | Status | Color | Meaning |
|------|--------|-------|---------|
| ○ | Pending | Gray | Not started |
| ⏳ | Waiting | Yellow | Waiting for approval or dependency |
| ▶ | Running | Blue | Currently executing |
| ✓ | Success | Green | Completed successfully |
| ✗ | Failed | Red | Step failed |
| ⊘ | Skipped | Gray | Condition not met |
| ⊗ | Cancelled | Gray | Manually stopped |

---

## Real-Time Logs

Click any step to view its output in the log panel.

### Log Controls

| Button | Description |
|--------|-------------|
| **Pause** | Stop auto-scroll |
| **Resume** | Continue auto-scroll |
| **Download** | Save logs as file |
| **Search** | Filter log output |

### Log Filtering

| Filter | Description |
|--------|-------------|
| **All** | Show everything |
| **Output** | Standard output only |
| **Errors** | Errors and warnings |

---

## Handling Approvals

When a workflow reaches an approval step, it pauses and notifies approvers.

### Approval Actions

Approve

Workflow continues to next step

Reject

Workflow fails with rejection reason

### Approval Flow

1. Review the request message and context

2. Click **View Plan** to see proposed changes

3. Click **Approve** or **Reject**

4. Optionally add a comment

---

## Handling Failures

When a step fails, the workflow stops and shows error details.

### Retry Options

| Option | Description |
|--------|-------------|
| **Retry Step** | Run the failed step again |
| **Retry From Here** | Restart from this step forward |
| **Skip Step** | Continue to next step (if allowed) |

### Cancel Options

| Option | Description |
|--------|-------------|
| **Cancel** | Stop the workflow immediately |
| **Cancel with Cleanup** | Run destroy to revert IaC changes |

---

## Execution History

View past workflow runs from the History tab.

| Column | Description |
|--------|-------------|
| **Run ID** | Unique execution identifier |
| **Status** | Success, Failed, Cancelled |
| **Triggered By** | Manual, Schedule, Webhook, Git, Incident |
| **Started** | When execution began |
| **Duration** | Total execution time |
| **User** | Who triggered it |

### Filters

| Filter | Options |
|--------|---------|
| **Status** | All, Success, Failed, Cancelled |
| **Triggered By** | All, Manual, Schedule, Webhook, Git |
| **Date Range** | Last 24h, 7d, 30d, Custom |

---

## Outputs

After successful completion, view step outputs in the Outputs tab.

```json
{
  "plan": {
    "add": 3,
    "change": 1,
    "destroy": 0
  },
  "apply": {
    "vpc_id": "vpc-12345",
    "subnet_ids": ["subnet-a", "subnet-b"]
  }
}
```

---

## Example: Successful Deployment

### Execution Summary

```
Workflow: production-deploy
Run ID:   wfr_8x7y6z5w
Status:   Completed ✓
Duration: 5m 32s
Triggered: Git Push (main @ abc1234)
```

### Step Results

```
Step Progress
─────────────────────────────────────
1. Plan           ✓  12s
   └─ 3 to add, 1 to change

2. Approval       ✓  4m 32s
   └─ Approved by jane@example.com

3. Apply          ✓  45s
   └─ 3 added, 1 changed

4. Health Check   ✓  2s
   └─ HTTP 200 OK

5. Notify         ✓  1s
   └─ Slack message sent
```

### Terraform Output

```
Apply complete! Resources: 3 added, 1 changed, 0 destroyed.

Outputs:

api_endpoint = "https://api.example.com"
vpc_id = "vpc-0abc123def456"
```

---

## Example: Handling a Failed Deploy

### Failure State

```
Workflow: production-deploy
Run ID:   wfr_fail123
Status:   Failed ✗
Duration: 2m 15s
```

### Step Results

```
Step Progress
─────────────────────────────────────
1. Plan           ✓  12s
2. Approval       ✓  1m 45s
3. Apply          ✗  18s  ← FAILED
4. Health Check   ⊘  Skipped
5. Notify         ⊘  Skipped
```

### Error Details

```
Step: Apply
Status: Failed
Duration: 18s
Exit Code: 1

Error:
  Error creating RDS instance: InvalidParameterValue
  The parameter MasterUserPassword is not a valid password.
  Password must be at least 8 characters.

Actions:
  [View Full Log]  [Retry Step]  [Cancel]
```

### Resolution

1. Review the error message

2. Fix the Terraform variable (update password length)

3. Click **Retry Step** to re-run Apply

4. Workflow resumes from Apply step

### After Retry

```
Step Progress (Retried)
─────────────────────────────────────
1. Plan           ✓  12s
2. Approval       ✓  1m 45s
3. Apply          ✓  52s  ← Retry succeeded
4. Health Check   ✓  2s
5. Notify         ✓  1s

Status: Completed ✓
Total Duration: 4m 52s (including retry)
```

---

## Troubleshooting

Workflow Stuck on Approval

Check that approvers have access. Verify email/Slack notifications are configured. Approvers can approve from the workflow execution page.

Step Timeout

Increase step timeout in configuration. Check for network issues or slow external APIs. Consider breaking into smaller steps.

Terraform State Lock

Another apply may be running. Check for concurrent workflow executions. Use workflow concurrency settings to prevent conflicts.

Webhook Not Triggering

Verify webhook secret is correct. Check that workflow is Active (not Paused). Review webhook logs in trigger history.
