<span id="重试计算资源"></span>

# Retry a compute resource

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Retry the target compute instance as a configured administrator and return the instance read again after the operation.

```text
POST https://api.moi.matrixorigin.cn/v5/admin/compute-resources/{id}/retry
```

<span id="调用前准备"></span>

## Before you call this API

Prepare a valid identity, configured compute specification administrator eligibility, and an accessible authentication workspace for this deployment. Workspace Owner privileges or Genesis administrative scopes do not substitute for them. Replace example IDs with targets you are authorized to read or operate on. See [Compute Instances](../../../../../developer/cli/tasks/compute-resources.md).

First confirm the parent instance is ERROR. A compare-and-swap (CAS) operation against the expected previous state resets the parent target state to IDLE, followed by a separate read. This call does not start Workers. Concurrent operations may change the read result; check the response and subsequent runtime state. Current typed compute resource models in all three clients do not declare nonempty py_requirements_txt/sha response fields. Confirm compatibility separately for instances with custom dependencies. Retain HTTP status and response using raw HTTP. After a client decoding error, read the instance before concluding that no operation occurred.

<span id="请求参数"></span>

## Request parameters

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
curl -X POST "https://api.moi.matrixorigin.cn/v5/admin/compute-resources/cr-example/retry" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $AUTH_WORKSPACE_ID"
```

:::::
:::::{tab-item} Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `X-API-Key` | string | Yes in example | Valid personal access token for a compute specification administrator configured in this deployment. |
| `X-Workspace-ID` | string | Yes | Exactly one nonempty authentication workspace accessible to the current principal; not a filter for the target instance workspace. |
| `id` | string | Yes | Target instance ID. The service resolves the owning workspace from this ID. |

This API does not read a business request body. Do not submit a target workspace or state in the body.
:::::
::::::
:::::::

<span id="成功响应"></span>

## Successful response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "id": "cr-example",
    "workspace_id": "target-workspace",
    "name": "示例实例",
    "description": "",
    "kind": "task",
    "spec_id": "spec-example",
    "cpu": 1,
    "memory_gib": 4,
    "gpu": 0,
    "cpu_milli": 1000,
    "memory_mib": 4096,
    "gpu_count": 0,
    "gpu_memory_mib": 0,
    "gpu_cores": 0,
    "min_replicas": 0,
    "max_replicas": 2,
    "current_replicas": 0,
    "desired_replicas": 0,
    "go_worker_image_id": "",
    "python_worker_image_id": "",
    "worker_images": [
      {
        "worker_type": "python-worker",
        "image_id": "image-example",
        "platform": "linux"
      }
    ],
    "platform": "linux",
    "auto_suspend_minutes": 30,
    "scale_reason": "retry",
    "is_default": false,
    "status": "IDLE",
    "status_message": "",
    "created_by": "creator-example",
    "allowed_actions": [],
    "created_at": "2026-11-12T07:00:00Z",
    "updated_at": "2026-11-12T07:00:00Z"
  }
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | OK on success. |
| `msg` | string | OK on success. |
| `data` | object | Data currently read or returned after the operation. |
| `data.id` | string | Compute instance ID. |
| `data.workspace_id` | string | The workspace that owns the instance, separate from the authentication header. |
| `data.name` | string | Instance name. |
| `data.description` | string | Instance description; may be an empty string. |
| `data.kind` | string | task or query. |
| `data.spec_id` | string | Associated specification ID. |
| `data.cpu` | integer | Legacy CPU specification in cores; do not confuse it with cpu_milli. |
| `data.memory_gib` | integer | Legacy memory specification in GiB. |
| `data.gpu` | integer | Legacy GPU specification. |
| `data.cpu_milli` | integer | CPU specification in millicores. |
| `data.memory_mib` | integer | Memory specification in MiB. |
| `data.gpu_count` | integer | Number of GPUs in the specification. |
| `data.gpu_memory_mib` | integer | GPU memory specification in MiB. |
| `data.gpu_cores` | integer | GPU core specification. |
| `data.min_replicas` | integer | Configured minimum replicas, distinct from currently observed replicas. |
| `data.max_replicas` | integer | Replica limit per Worker type, not a combined limit across all types. |
| `data.current_replicas` | integer | Current aggregate instance replica count, separate from observations by type. |
| `data.desired_replicas` | integer | Target instance replica count; does not indicate readiness. |
| `data.go_worker_image_id` | string | Legacy Go Worker image ID; may be empty. |
| `data.python_worker_image_id` | string | Legacy Python Worker image ID; may be empty. |
| `data.worker_images` | object (array of objects), optional | Images selected by Worker type; may be omitted. See the item fields below. |
| `data.platform` | string | Worker platform configuration. |
| `data.auto_suspend_minutes` | integer | Auto-suspension setting in minutes, not a completion-time guarantee for this operation. |
| `data.scale_reason` | string | Most recent scaling or lifecycle reason. |
| `data.is_default` | boolean | Whether this is the default instance; may be false. |
| `data.status` | string | Parent instance state. The current model includes IDLE, DEPLOYING, SCALING, ACTIVE, DRAINING, SUSPENDED, TERMINATING, and ERROR. Keep this separate from Worker states. |
| `data.status_message` | string | Status text; may be empty. |
| `data.py_requirements_txt` | string, optional | Optional saved Python dependency text; may be returned when nonempty. Not declared in the current typed SDK model. |
| `data.py_requirements_sha` | string, optional | Optional saved dependency content hash; not declared in the current typed SDK model. |
| `data.py_deps` | object, optional | Optional observation object declared by the DTO, but not populated by the converters for these three lifecycle APIs. Do not rely on it for installation progress. |
| `data.created_by` | string | Creating principal. |
| `data.allowed_actions` | string (array of strings) | Allowed-action projection. These three lifecycle APIs do not construct actions separately; an empty array does not determine administrator eligibility. |
| `data.last_activation_at` | string, optional | Last activation time in RFC3339; omitted if not recorded. |
| `data.last_active_at` | string, optional | Last activity time in RFC3339; omitted if not recorded. |
| `data.created_at` | string | Creation time in RFC3339. |
| `data.updated_at` | string | Update time in RFC3339; not a caller-supplied concurrency version. |

See [Common objects](compute-runtime-admin-objects.md) for nested images, declared observation objects, and parent/Worker state relationships.
:::::
::::::
:::::::

<span id="错误响应"></span>

## Error response

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{"code":"INVALID_PARAMS","msg":"invalid compute resource request","data":null}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | Depends on the failure stage and operation. |
| `msg` | string | Error text; some branches are localized and do not expose unclassified underlying errors. |
| `data` | null | null in this example; shared authentication error branches may omit it. |

| HTTP / code | Conditions and recovery |
| --- | --- |
| 400 / INVALID_PARAMS | Missing authentication workspace, principal, or resource ID. |
| 403 / ErrForbidden | Administrator facts, the current principal, or workspace access was denied at the permission boundary. |
| 503 / ErrServiceUnavailable | Classified shared authorization unavailability; does not cover every catalog failure. |
| 404 / RETRY_ADMIN_FAILED | Target instance not found; this branch uses a different machine code from NOT_FOUND in runtime queries. |
| 409 / CANNOT_RETRY | Parent instance is not in the required ERROR state. |
| 409 / LIFECYCLE_CONFLICT | The expected-state CAS for recovery/retry conflicts with a concurrent change. |
| 409 / RESOURCE_BUSY | Classified lifecycle lease loss or ongoing Cloud teardown. Check the original operation first. |
| 503 / RETRY_ADMIN_FAILED | Classified runtime service configuration missing. |
| 500 / RETRY_ADMIN_FAILED | Unclassified failure stopping, writing state, reading again, or reading catalog facts. Check the actual state after the error. |

See [Errors and recovery](compute-runtime-admin-errors-recovery.md) for handlers, identities, and recovery stages.
:::::
::::::
:::::::
