OAPI: add may-worker-run endpoint

Add an endpoint for Workers to poll while they're running a task, to see
if they're allowed to keep running it.
This commit is contained in:
Sybren A. Stüvel 2022-05-12 11:02:24 +02:00
parent bedf10e435
commit 52e9db6ef4

View File

@ -221,6 +221,34 @@ paths:
schema: schema:
$ref: "#/components/schemas/Error" $ref: "#/components/schemas/Error"
/api/worker/task/{task_id}/may-i-run:
summary: Workers check whether they're allowed to keep running this task.
get:
operationId: mayWorkerRun
summary: >
The response indicates whether the worker is allowed to run / keep
running the task. Optionally contains a queued worker status change.
security: [{ worker_auth: [] }]
tags: [worker]
parameters:
- name: task_id
in: path
required: true
schema: { type: string, format: uuid }
responses:
"200":
description: normal response
content:
application/json:
schema:
$ref: "#/components/schemas/MayKeepRunning"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
## Jobs ## Jobs
/api/jobs/types: /api/jobs/types:
@ -727,6 +755,20 @@ components:
type: string type: string
description: Log lines for this task, will be appended to logs sent earlier. description: Log lines for this task, will be appended to logs sent earlier.
MayKeepRunning:
type: object
description: Indicates whether the worker may keep running the task.
properties:
"mayKeepRunning": { type: boolean }
"reason": { type: string }
"statusChangeRequested":
type: boolean
description: >
Indicates that a status change requested for the worker. It should
use the `workerState` operation to determine which state to go to
next. If this is `true`, `mayKeepRunning` MUST be `false`.
required: ["mayKeepRunning", "reason", "statusChangeRequested"]
JobStatus: JobStatus:
type: string type: string
enum: enum: