Tasks

Stops the task, that is, cancels image pulling if in progress, stops the container if running, and sets the status to terminated. No-op if the task is already terminated

post/tasks/{id}/terminate

Request

  • Base URL: http://localhost:10998/api
  • URL: http://localhost:10998/api/tasks/{id}/terminate
  • Auth: none declared

Path parameters

idstring required

Unique task ID assigned by dstack server

Example:23a2c7a0-6c88-48ee-8028-b9ad9f6f5c24

Request body

termination_reason'executor_error' | 'creating_container_error' | 'container_exited_with_error' | 'done_by_runner' | 'terminated_by_user' | 'terminated_by_server' | 'max_duration_exceeded'
termination_messagestring
timeoutboolean

Seconds to wait before killing the container. If zero, kill the container immediately (no graceful shutdown)

Example request

{
  "termination_reason": "TERMINATED_BY_USER"
}

Response

Task info

idstring required

Unique task ID assigned by dstack server

status'pending' | 'preparing' | 'pulling' | 'creating' | 'running' | 'terminated' required
termination_reason'executor_error' | 'creating_container_error' | 'container_exited_with_error' | 'done_by_runner' | 'terminated_by_user' | 'terminated_by_server' | 'max_duration_exceeded' required
termination_messagestring required

A shim-generated message or N last lines from the container logs

container_namestring required
container_idstring required
gpu_idsGpuID[] nullable required

An array of GPU identifiers or null if this information is not yet available

Example response

{
  "id": "23a2c7a0-6c88-48ee-8028-b9ad9f6f5c24",
  "status": "terminated",
  "ports": [
    {
      "host": 32770,
      "container": 80
    }
  ],
  "container_name": "horrible-mule-1-0-0-44f7cb95",
  "container_id": "a6bb8d4bb8af8ec72482ecd194ff92fac9974521aa5ad8a46abfc4f0ba858775",
  "gpu_ids": [
    "GPU-2b79666e-d81f-f3f8-fd47-9903f118c3f5"
  ]
}

Changes

    • info

      api tag Tasks added

    • breaking

      removed the enum value CONTAINER_EXITED_WITH_ERROR of the request property ////

    • breaking

      removed the enum value CREATING_CONTAINER_ERROR of the request property ////

    • breaking

      removed the enum value DONE_BY_RUNNER of the request property ////

    • breaking

      removed the enum value EXECUTOR_ERROR of the request property ////

    • breaking

      removed the enum value TERMINATED_BY_SERVER of the request property ////

    • breaking

      removed the enum value TERMINATED_BY_USER of the request property ////

    • warning

      added the new container_exited_with_error enum value to the response property for the response status

    • warning

      added the new creating_container_error enum value to the response property for the response status

    • warning

      added the new done_by_runner enum value to the response property for the response status

    • warning

      added the new executor_error enum value to the response property for the response status

    • warning

      added the new max_duration_exceeded enum value to the response property for the response status

    • warning

      added the new terminated_by_server enum value to the response property for the response status

    • warning

      added the new terminated_by_user enum value to the response property for the response status

    • info

      added the new container_exited_with_error enum value to the request property ////

    • info

      added the new creating_container_error enum value to the request property ////

    • info

      added the new done_by_runner enum value to the request property ////

    • info

      added the new executor_error enum value to the request property ////

    • info

      added the new max_duration_exceeded enum value to the request property ////

    • info

      added the new terminated_by_server enum value to the request property ////

    • info

      added the new terminated_by_user enum value to the request property ////

    • info

      removed the CONTAINER_EXITED_WITH_ERROR enum value from the response property for the response status

    • info

      removed the CREATING_CONTAINER_ERROR enum value from the response property for the response status

    • info

      removed the DONE_BY_RUNNER enum value from the response property for the response status

    • info

      removed the EXECUTOR_ERROR enum value from the response property for the response status

    • info

      removed the TERMINATED_BY_SERVER enum value from the response property for the response status

    • info

      removed the TERMINATED_BY_USER enum value from the response property for the response status