OAPI: allow worker status change requests

This also introduces the 'lazy' status change boolean, which indicates
whether the status change should interrupt the worker's current task
(lazy=false), or only take effect after the task is finished (lazy=true).
This commit is contained in:
Sybren A. Stüvel 2022-05-31 17:17:37 +02:00
parent dd3f99ebaa
commit cfb17b178d

View File

@ -281,6 +281,33 @@ paths:
application/json: application/json:
schema: { $ref: "#/components/schemas/Worker" } schema: { $ref: "#/components/schemas/Worker" }
/api/worker-mgt/workers/{worker_id}/setstatus:
summary: Request a status change for the given worker.
post:
operationId: requestWorkerStatusChange
tags: [worker-mgt]
parameters:
- name: worker_id
in: path
required: true
schema: { type: string, format: uuid }
requestBody:
description: The status change to request.
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/WorkerStatusChangeRequest"
responses:
"204":
description: Status change was accepted.
default:
description: Unexpected error.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
## Jobs ## Jobs
/api/jobs/types: /api/jobs/types:
@ -1353,7 +1380,6 @@ components:
type: object type: object
description: > description: >
Subset of a Worker, sent over SocketIO when a worker changes. Subset of a Worker, sent over SocketIO when a worker changes.
For new workers, `previous_status` will be excluded.
properties: properties:
"id": "id":
type: string type: string
@ -1367,6 +1393,11 @@ components:
"status": { $ref: "#/components/schemas/WorkerStatus" } "status": { $ref: "#/components/schemas/WorkerStatus" }
"previous_status": { $ref: "#/components/schemas/WorkerStatus" } "previous_status": { $ref: "#/components/schemas/WorkerStatus" }
"status_requested": { $ref: "#/components/schemas/WorkerStatus" } "status_requested": { $ref: "#/components/schemas/WorkerStatus" }
"lazy_status_request":
type: boolean
description: >
Whether the worker is allowed to finish its current task before the
status change is enforced. Mandatory when `status_requested` is set.
"version": { type: string } "version": { type: string }
required: [id, nickname, updated, status, version] required: [id, nickname, updated, status, version]
@ -1415,6 +1446,7 @@ components:
"nickname": { type: string } "nickname": { type: string }
"status": { $ref: "#/components/schemas/WorkerStatus" } "status": { $ref: "#/components/schemas/WorkerStatus" }
"status_requested": { $ref: "#/components/schemas/WorkerStatus" } "status_requested": { $ref: "#/components/schemas/WorkerStatus" }
"lazy_status_request": { type: boolean }
# These will be implemented soon: # These will be implemented soon:
# "task_id": # "task_id":
# type: string # type: string
@ -1452,6 +1484,18 @@ components:
- version - version
- supported_task_types - supported_task_types
WorkerStatusChangeRequest:
type: object
description: Request for a Worker to change its status.
properties:
"status_requested": { $ref: "#/components/schemas/WorkerStatus" }
"is_lazy":
type: boolean
description: >
Whether the status change should happen immediately, or after the
worker's current task is finished.
required: [status_requested, is_lazy]
securitySchemes: securitySchemes:
worker_auth: worker_auth:
description: Username is the worker ID, password is the secret given at worker registration. description: Username is the worker ID, password is the secret given at worker registration.