feat: dynamic execution mode — Undecided tasks, two-phase dispatch, assign API
- ExecutionMode enum adds Undecided variant (default for new tasks)
- Webhook creates tasks as Undecided instead of hardcoded SshCli
- Dispatch loop: Phase 1 matches ssh_cli hosts, Phase 2 marks remaining as HttpPull
- Dequeue now returns http_pull AND undecided tasks (atomic claim)
- New endpoint: POST /api/v1/tasks/{id}/assign for coordinator explicit assignment
- Backward compatible: existing SshCli/HttpPull tasks unaffected
- 37 tests passing (6 new)
This commit is contained in:
parent
a18cb2824e
commit
48c93e2ce9
13 changed files with 639 additions and 13 deletions
|
|
@ -236,7 +236,7 @@ curl http://FLEET_API_URL:PORT/api/v1/tasks/org%2Frepo%2342
|
|||
POST /api/v1/tasks/dequeue
|
||||
```
|
||||
|
||||
Requires Bearer token if `http_pull_token` is configured. Only returns tasks with `execution_mode = http_pull`.
|
||||
Requires Bearer token if `http_pull_token` is configured. Returns tasks with `execution_mode = http_pull` and may also claim `undecided` tasks, atomically converting them to `http_pull` when dequeued.
|
||||
|
||||
**Request:**
|
||||
|
||||
|
|
@ -258,6 +258,33 @@ curl -X POST http://FLEET_API_URL:PORT/api/v1/tasks/dequeue \
|
|||
|
||||
---
|
||||
|
||||
### Assign Task
|
||||
|
||||
```
|
||||
POST /api/v1/tasks/{task_id}/assign
|
||||
```
|
||||
|
||||
Explicitly assign a created task to a specific agent or host.
|
||||
|
||||
**Request:**
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| agent_id | string | yes | Registered http_pull agent ID or configured ssh_cli host ID |
|
||||
| execution_mode | string | no | Optional override: `ssh_cli` or `http_pull`. If omitted, the server auto-detects it from the target. |
|
||||
|
||||
**Response:** `200 OK` — updated [Task](#task-object).
|
||||
|
||||
**Errors:** `404` if task or agent not found. `400` if task status is not assignable.
|
||||
|
||||
```bash
|
||||
curl -X POST http://FLEET_API_URL:PORT/api/v1/tasks/org%2Frepo%2342/assign \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"agent_id": "worker-03"}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Update Task Status (http_pull only)
|
||||
|
||||
```
|
||||
|
|
@ -455,7 +482,7 @@ Receives Forgejo webhook events. Requires HMAC-SHA256 signature header.
|
|||
|
||||
**Priority values:** `low`, `normal`, `high`, `urgent`
|
||||
|
||||
**Execution mode values:** `ssh_cli`, `http_pull`
|
||||
**Execution mode values:** `undecided`, `ssh_cli`, `http_pull`
|
||||
|
||||
### Receipt Object
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue