Roll back a task

2023-08-22 02:46:05  Updated

Description

You can call this operation to roll back all failed subtasks of a task.

Call description

Prerequisite

You have the TASK_MANAGER permissions.

Request path

POST /api/v2/tasks/instances/{taskInstanceId}/rollback

Request parameters

Parameter Type Required Example value Description
taskInstanceId Long Yes 1000 The ID of the task instance.

Response parameters

Parameter Type Description
data Object The data requested by the WrappedTaskInstance object.
successful Boolean Indicates whether the request was successful.
timestamp Datetime The timestamp when the server completed the request.
duration Integer The time taken by the server to process the request, in milliseconds.
status Integer An HTTP status code.
traceId String The trace ID of the request. This trace ID is used for troubleshooting.
server String The address of the application server that responded to the request.
data Object The data requested by the SubtaskInstance object.
successful Boolean Indicates whether the request was successful.
timestamp Datetime The timestamp when the server completed the request.
duration Integer The time taken by the server to process the request, in milliseconds.
status Integer An HTTP status code.

Data structure of WrappedTaskInstance

Parameter Type Description
id Long The ID of the software package.
name String The name of the software package.
taskDefinitionId Long The ID of the task definition.
├─ cluster Object The cluster information.
├─ id Long The ID of the OceanBase cluster generated by the OCP system.
├─ name String The name of the OceanBase cluster.
├─ obClusterId Long The ID of the OceanBase cluster generated by the OceanBase Database system.
├─ type String The type of the OceanBase cluster. Valid values: * PRIMARY * STANDBY
├─ tenant Object The tenant information.
├─ id Long The ID of the tenant generated by the OCP system..
├─ name String The name of the tenant.
├─ obTenantId Long The ID of the tenant generated by the OceanBase Database system.
├─ mode String The mode of the tenant. Valid values: * ORACLE * MYSQL
├─ creator Object The information about the task creator.
├─ id Long The ID of the creator.
├─ name String The username of the creator.
status Integer The status of the task. Valid values: * RUNNING * FAILED * SUCCESSFUL
type String The type of the task. Valid values: * MANUAL: indicates a manually initiated task. * SYS_ONECE: indicates a one-time task executed by the system. * SCHEDULED: indicates a non-built-in scheduled task. * SYS_SCHEDULED: indicates a built-in scheduled task.
operation String The operation performed by the task. Valid values: * EXECUTE * RETRY * ROLLBACK * SKIP * CANCEL
executor String The host that executed the task.
prohibitRollback Boolean Indicates whether rollback was supported by the task.
subtasks ObjectArray The SubtaskInstance array, which contains the information of all subtasks.
createTime String The time when the task was created.
startTime String The start time of the task.
finishTime String The end time of the task.

Data structure of SubtaskInstance

Parameter Type Description
id Long The ID of the subtask instance.
name String The name of the subtask.
seriesId Long The serial number of the subtask.
description String The description of the subtask.
timeout Integer The timeout period of the subtask, in seconds.
status String The status of the subtask. Valid values: * PENDING * READY * RUNNING * CANCELING * FAILED * SUCCESSFUL
operation String The operation performed by the subtask. Valid values: * EXECUTE * RETRY * ROLLBACK * SKIP * CANCEL
executor String The node that executed the subtask.
runTime Integer The number of executions of the subtask.
nodeType String The node type, for example, JAVA_TASK.
paralleIdx Integer The index of a parallel subtask. -1 indicates that the subtask is not a parallel subtask.
upstreams LongArray The IDs of upstream subtasks.
downstream LongArray The IDs of downstream subtasks.
prohibitRollback Boolean Indicates whether rollback was supported by the subtask.
createTime String The time when the subtask was created.
startTime String The start time of the subtask.
finishTime String The end time of the subtask.

Examples

Sample request

POST /api/v2/tasks/instances/100/rollback

Sample response

{
  "data": {
    "createTime": "2021-08-25T15:09:31+08:00",
    "creator": {
      "id": 100,
      "name": "admin"
    },
    "executor": "xxx.xxx.xxx.xxx",
    "finishTime": "2021-08-25T15:09:54.067+08:00",
    "id": 35000312,
    "name": "Reinstall OCP agent",
    "operation": "EXECUTE",
    "prohibitRollback": false,
    "startTime": "2021-08-25T15:09:31.74+08:00",
    "status": "SUCCESSFUL",
    "subtasks": [
      {
        "createTime": "2021-08-25T15:09:31+08:00",
        "description": "Install ocp agent",
        "downstreams": [
          13000334
        ],
        "executor": "xxx.xxx.xxx.xxx",
        "finishTime": "2021-08-25T15:09:52.182+08:00",
        "id": 13000336,
        "name": "Install ocp agent",
        "nodeType": "JAVA_TASK",
        "operation": "EXECUTE",
        "parallelIdx": -1,
        "prohibitRollback": false,
        "runTime": 1,
        "seriesId": 0,
        "startTime": "2021-08-25T15:09:36.821+08:00",
        "status": "SUCCESSFUL",
        "timeout": 5400,
        "upstreams": [
          13000333
        ]
      },
      {
        "createTime": "2021-08-25T15:09:31+08:00",
        "description": "Finish reinstalling OCP agent",
        "downstreams": [],
        "executor": "xxx.xxx.xxx.xxx",
        "finishTime": "2021-08-25T15:09:53.252+08:00",
        "id": 13000334,
        "name": "Finish reinstalling OCP agent",
        "nodeType": "JAVA_TASK",
        "operation": "EXECUTE",
        "parallelIdx": -1,
        "prohibitRollback": false,
        "runTime": 1,
        "seriesId": 1,
        "startTime": "2021-08-25T15:09:53.062+08:00",
        "status": "SUCCESSFUL",
        "timeout": 60,
        "upstreams": [
          13000336
        ]
      },
      {
        "createTime": "2021-08-25T15:09:31+08:00",
        "description": "Uninstall ocp agent",
        "downstreams": [
          13000336
        ],
        "executor": "xxx.xxx.xxx.xxx",
        "finishTime": "2021-08-25T15:09:35.626+08:00",
        "id": 13000333,
        "name": "Uninstall ocp agent",
        "nodeType": "JAVA_TASK",
        "operation": "EXECUTE",
        "parallelIdx": -1,
        "prohibitRollback": false,
        "runTime": 1,
        "seriesId": 2,
        "startTime": "2021-08-25T15:09:33.732+08:00",
        "status": "SUCCESSFUL",
        "timeout": 1800,
        "upstreams": [
          13000335
        ]
      },
      {
        "createTime": "2021-08-25T15:09:31+08:00",
        "description": "Prepare reinstalling OCP agent",
        "downstreams": [
          13000333
        ],
        "executor": "xxx.xxx.xxx.xxx",
        "finishTime": "2021-08-25T15:09:33.082+08:00",
        "id": 13000335,
        "name": "Prepare reinstalling OCP agent",
        "nodeType": "JAVA_TASK",
        "operation": "EXECUTE",
        "parallelIdx": -1,
        "prohibitRollback": false,
        "runTime": 1,
        "seriesId": 3,
        "startTime": "2021-08-25T15:09:32.688+08:00",
        "status": "SUCCESSFUL",
        "timeout": 60,
        "upstreams": []
      }
    ],
    "taskDefinitionId": -1,
    "type": "MANUAL"
  },
  "duration": 55,
  "server": "xxx.xxx.xxx.xxx",
  "status": 200,
  "successful": true,
  "timestamp": "2021-08-25T15:10:13.176+08:00",
  "traceId": "0bc49000675d41af"
}

Contact Us