本页介绍了如何列出所有长时间运行的操作,以及如何查看长时间运行的操作的状态。
如需检查长时间运行的操作的状态并显示任何其他错误详情,您需要先获取 OPERATION_NAME 的值,然后才能请求状态。
ListOperations
如需列出所有长时间运行的操作,请发送以下请求:
curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://blockchainnodeengine.googleapis.com/v1/projects/PROJECT_ID/\
locations/LOCATION/operations
其中:
- PROJECT_ID 是您的 Google Cloud 项目 ID。例如
my-project-id
。 - LOCATION 是资源的托管位置。例如
us-central1
。
以下是上述命令的示例响应:
{
"operations": [
{
"name": "projects/my-project-id/locations/us-central1/operations/operation-1683321573175-5faf8d8696fe0-5f1906e4-eb1b6828",
"metadata": {
"@type": "type.googleapis.com/google.cloud.blockchainnodeengine.v1.OperationMetadata",
"createTime": "2023-05-05T21:19:33.245698045Z",
"endTime": "2023-05-05T21:58:44.520319810Z",
"target": "projects/my-project-id/locations/us-central1/blockchainNodes/my-new-node-2",
"verb": "create",
"requestedCancellation": false,
"apiVersion": "v1"
},
"done": true,
"response": {
"@type": "type.googleapis.com/google.cloud.blockchainnodeengine.v1.BlockchainNode",
"name": "projects/my-project-id/locations/us-central1/blockchainNodes/my-new-node-2",
"createTime": "2023-05-05T21:19:33.308756Z",
"updateTime": "2023-05-05T21:58:44.513286Z",
"labels": {
"label-key": "label-value"
},
"blockchainType": "ETHEREUM",
"connectionInfo": {
"ipInfo": {
"rpcIpv4Address": "203.0.113.1"
},
"endpointInfo": {
"jsonRpcApiEndpoint": "json-rpc.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com",
"websocketsApiEndpoint": "ws.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com"
}
},
"ethereumDetails": {
"network": "MAINNET",
"nodeType": "FULL",
"executionClient": "GETH",
"consensusClient": "LIGHTHOUSE",
"apiEnableAdmin": false,
"apiEnableDebug": false,
"additionalEndpoints": {
"beaconApiEndpoint": "beacon.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com",
"beaconPrometheusMetricsApiEndpoint": "bc-mc.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com"
}
},
"state": "RUNNING"
}
}
]
}
记下 OPERATION_ID,该值如下所示:
"name": "projects/my-project-id/locations/us-central1/operations/
operation-1683321573175-5faf8d8696fe0-5f1906e4-eb1b6828",
GetOperation
当您发送请求并收到响应(例如来自 CreateBlockchainNode 或 DeleteBlockchainNode)时,响应中会包含 OPERATION_ID:
"name": "projects/my-project-id/locations/us-central1/operations/
operation-1683321573175-5faf8d8696fe0-5f1906e4-eb1b6828",
在此示例中,您将 OPERATION_NAME 设置为 operation-1683321573175-5faf8d8696fe0-5f1906e4-eb1b6828
。
您还可以从 ListOperations 命令的结果中获取操作名称。
获取 OPERATION_NAME 的值后,发送以下请求:
curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://blockchainnodeengine.googleapis.com/v1/projects/PROJECT_ID/\
locations/LOCATION/operations/OPERATION_NAME
其中:
- PROJECT_ID 是您的 Google Cloud 项目 ID。例如
my-project-id
。 - LOCATION 是资源的托管位置。例如
us-central1
。 - OPERATION_NAME 是用于指定操作的字符串。例如
operation-1683321573175-5faf8d8696fe0-5f1906e4-eb1b6828
。
以下是上述命令的示例响应:
{
"name": "projects/my-project-id/locations/us-central1/operations/operation-1683321573175-5faf8d8696fe0-5f1906e4-eb1b6828",
"metadata": {
"@type": "type.googleapis.com/google.cloud.blockchainnodeengine.v1.OperationMetadata",
"createTime": "2023-05-05T21:19:33.245698045Z",
"endTime": "2023-05-05T21:58:44.520319810Z",
"target": "projects/my-project-id/locations/us-central1/blockchainNodes/my-new-node-2",
"verb": "create",
"requestedCancellation": false,
"apiVersion": "v1"
},
"done": true,
"response": {
"@type": "type.googleapis.com/google.cloud.blockchainnodeengine.v1.BlockchainNode",
"name": "projects/my-project-id/locations/us-central1/blockchainNodes/my-new-node-2",
"createTime": "2023-05-05T21:19:33.308756Z",
"updateTime": "2023-05-05T21:58:44.513286Z",
"labels": {
"label-key": "label-value"
},
"blockchainType": "ETHEREUM",
"connectionInfo": {
"ipInfo": {
"rpcIpv4Address": "203.0.113.1"
},
"endpointInfo": {
"jsonRpcApiEndpoint": "json-rpc.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com",
"websocketsApiEndpoint": "ws.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com"
}
},
"ethereumDetails": {
"network": "MAINNET",
"nodeType": "FULL",
"executionClient": "GETH",
"consensusClient": "LIGHTHOUSE",
"apiEnableAdmin": false,
"apiEnableDebug": false,
"additionalEndpoints": {
"beaconApiEndpoint": "beacon.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com",
"beaconPrometheusMetricsApiEndpoint": "bc-mc.4amkczs2vkh8hjtghcipu7y2t.blockchainnodeengine.com"
}
},
"state": "RUNNING"
}
}