Queries the execution list and status of Cloud Assistant commands.
Operation description
-
After you run a command, it does not necessarily run successfully or produce the expected results. You need to check the actual execution results by viewing the return values of this operation. The actual output takes precedence.
-
You can query execution information from the last 30 days. A maximum of 10,000 execution records are retained.
-
You can subscribe to Cloud Assistant task status events to obtain task results through events, avoiding frequent polling and improving efficiency.
-
When querying the first page of a paging query, set only
MaxResultsto limit the number of entries returned. TheNextTokenvalue in the response serves as the credential for querying subsequent pages. When querying subsequent pages, set theNextTokenparameter to theNextTokenvalue obtained from the previous response, and setMaxResultsto limit the number of entries returned. -
Differences between
DescribeInvocationsandDescribeInvocationResults:- When a single
RunCommand/InvokeCommandcall specifies multiple instances:DescribeInvocationsreturns the execution status on each instance and the aggregation status across multiple instances.DescribeInvocationResultsreturns only the individual execution status on each instance, without the aggregation status across multiple instances.
- When a single
RunCommand/InvokeCommandcall specifies one instance:DescribeInvocationsandDescribeInvocationResultsare largely interchangeable and can replace each other.
When you need to view the execution history of scheduled (periodic) tasks or tasks that execute automatically on instance startup (
RepeatMode=Period, EveryReboot), onlyDescribeInvocationResultscan return historical execution records (you must specifyIncludeHistory=true).DescribeInvocationsreturns only the latest task status.When you need to view the command content and parameters, only
DescribeInvocationsreturnsCommandContent.
- When a single
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ecs:DescribeInvocations |
get |
Instance
Command
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The region ID. You can call DescribeRegions to query the most recent region list. |
cn-hangzhou |
| ResourceGroupId |
string |
No |
The ID of the resource group to which the command execution belongs. After you specify this parameter, the command execution results are filtered based on the ResourceGroupId specified when the command was run. |
rg-bp67acfmxazb4p**** |
| InvokeId |
string |
No |
The command execution ID. |
t-hz0jdfwd9f**** |
| CommandId |
string |
No |
The command ID. You can call DescribeCommands to query all available command IDs. |
c-hz0jdfwcsr**** |
| CommandName |
string |
No |
The command name. This parameter does not take effect if you also specify |
CommandTestName |
| CommandType |
string |
No |
The command type. Valid values:
|
RunShellScript |
| Timed |
boolean |
No |
Specifies whether the command will be automatically run in the future. Valid values:
Default value: false. |
true |
| InvokeStatus |
string |
No |
The overall execution status of the command. The overall execution status depends on the common execution status across one or more instances in the execution. Valid values:
|
Finished |
| InstanceId |
string |
No |
The instance ID. If you specify this parameter, all command execution records for the instance are queried. |
i-bp1i7gg30r52z2em**** |
| ContentEncoding |
string |
No |
The encoding mode of the
Default value: Base64. |
PlainText |
| IncludeOutput |
boolean |
No |
Specifies whether to return the command output in the results.
Default value: false. |
false |
| PageNumber |
integer |
No |
Note
This parameter is about to be deprecated. Use NextToken and MaxResults to complete paging query operations. |
1 |
| PageSize |
integer |
No |
Note
This parameter is about to be deprecated. Use NextToken and MaxResults to complete paging query operations. |
10 |
| MaxResults |
integer |
No |
The maximum number of entries per page for a paging query. Maximum value: 50. Default value: 10. |
10 |
| NextToken |
string |
No |
The pagination token. Set this parameter to the NextToken value returned in the previous API call. |
AAAAAdDWBF2 |
| RepeatMode |
string |
No |
The execution mode of the command. This parameter does not take effect if you also specify
Default value: empty, which indicates that all execution modes are queried. |
Once |
| Tag |
array<object> |
No |
The tags. |
|
|
object |
No |
The tags. |
||
| Value |
string |
No |
The tag value of the command execution. Valid values of N: 1 to 20. The tag value can be an empty string.
The tag value can be up to 128 characters in length and cannot contain |
TestValue |
| Key |
string |
No |
The tag key of the command execution. Valid values of N: 1 to 20. The tag key cannot be an empty string. If you use a single tag to filter resources, the resource count with this tag cannot exceed 1,000. If you use multiple tags to filter resources, the resource count with all specified tags attached cannot exceed 1,000. If the resource count exceeds 1,000, use the ListTagResources operation to execute the query. The tag key can be up to 64 characters in length and cannot start with |
TestKey |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| PageSize |
integer |
The number of entries per page. |
10 |
| RequestId |
string |
The request ID. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
| PageNumber |
integer |
The page number of the query results. |
1 |
| TotalCount |
integer |
The total number of commands. |
1 |
| NextToken |
string |
The pagination token returned in this call. |
AAAAAdDWBF2 |
| Invocations |
object |
||
| Invocation |
array<object> |
The command execution records. |
|
|
array<object> |
The time when the task was created. |
||
| OssOutputDelivery |
string |
The OSS delivery configuration for the command execution output. |
oss://testBucket/testPrefix |
| InvocationStatus |
string |
The overall execution status of the command. The overall execution status depends on the common execution status across all instances in this call. Valid values:
Note
The |
Running |
| Parameters |
string |
The custom parameters in the command. |
{} |
| Timed |
boolean |
Indicates whether the command will be automatically run in the future. |
false |
| CommandDescription |
string |
The command description. |
testDescription |
| Timeout |
integer |
The maximum timeout period for the command execution on ECS instances. Unit: seconds. If the command cannot be run for some reason, a timeout occurs. When a timeout occurs, the command process is forcefully terminated by canceling the PID of the command. |
60 |
| InvokeInstances |
object |
||
| InvokeInstance |
array<object> |
The target instance set type. |
|
|
object |
The execution status list. |
||
| Dropped |
integer |
The length of the truncated and discarded text after the text in the Output field exceeds 24 KB. |
0 |
| InvocationStatus |
string |
The command execution status on a single instance. Valid values:
|
Success |
| InstanceId |
string |
The instance ID. |
i-bp1i7gg30r52z2em**** |
| Timed |
boolean |
Indicates whether the command will be automatically run in the future. |
false |
| InstanceInvokeStatus |
string |
The command execution status on a single instance. Note
We recommend that you check the |
Finished |
| ExitCode |
integer |
The exit code of the command process. Valid values:
|
0 |
| ErrorInfo |
string |
The details of the command delivery failure or execution failure. Valid values:
|
the specified instance does not exists |
| StartTime |
string |
The time when the command started to run on the instance. |
2019-12-20T06:15:55Z |
| Repeats |
integer |
The number of times the command was run on the instance.
|
0 |
| OssOutputUri |
string |
The OSS file URI to which the command execution output is delivered. This field is an empty string when delivery fails or is in progress. |
oss://testBucket/testPrefix/output.txt |
| OssOutputStatus |
string |
The delivery status of the command execution output. Valid values:
|
Finished |
| OssOutputErrorCode |
string |
The fault code when delivery fails. This field is returned only when OssOutputStatus is Failed. Valid values:
|
CloudAssistant.UnsupportedInvocationStatus |
| OssOutputErrorInfo |
string |
The error details when delivery fails. This field is returned only when OssOutputStatus is Failed. |
The invocation status does not support output delivery. |
| FinishTime |
string |
The end time of the command process. |
2019-12-20T06:15:56Z |
| Output |
string |
The command output.
|
OutPutTestmsg |
| CreationTime |
string |
The start time of the command execution. |
2019-12-20T06:15:54Z |
| UpdateTime |
string |
The time when the command status was updated. |
2020-01-19T09:15:47Z |
| ErrorCode |
string |
The error code for command delivery failure or execution failure. Valid values:
|
InstanceNotExists |
| StopTime |
string |
The time when |
2020-01-19T09:15:47Z |
| CommandContent |
string |
The command content.
|
cnBtIC1xYSB8IGdyZXAgdnNm**** |
| WorkingDir |
string |
The working directory of the command execution. |
/home/ |
| RepeatMode |
string |
The execution mode of the command. Valid values:
|
Once |
| InvokeStatus |
string |
The overall execution status of the command. Note
We recommend that you check the |
Finished |
| CommandType |
string |
The command type. |
RunShellScript |
| Username |
string |
The username used to run the command on the ECS instance. |
test |
| ContainerId |
string |
The container ID. |
ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea**** |
| ContainerName |
string |
The container name. |
test-container |
| CreationTime |
string |
The time when the task was created. |
2020-01-19T09:15:46Z |
| Frequency |
string |
The schedule for the scheduled command execution. |
0 */20 * * * * |
| Launcher |
string |
The launcher for script execution. The launcher cannot exceed 1 KB in length. |
python3 -u {{ACS::ScriptFileName|Ext(".py")}} |
| CommandId |
string |
The command ID. |
c-hz0jdfwcsr**** |
| CommandName |
string |
The command name. |
CommandTestName |
| InvokeId |
string |
The command execution ID. |
t-hz0jdfwd9f**** |
| TerminationMode |
string |
The mode used when the task is stopped (manually stopped or interrupted due to timeout). Valid values:
|
ProcessTree |
| Tags |
object |
||
| Tag |
array<object> |
The tag information of the command execution. |
|
|
object |
The tag information of the command execution. |
||
| TagKey |
string |
The tag key of the command execution. |
owner |
| TagValue |
string |
The tag value of the command execution. |
zhangsan |
Examples
Success response
JSON format
{
"PageSize": 10,
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
"PageNumber": 1,
"TotalCount": 1,
"NextToken": "AAAAAdDWBF2",
"Invocations": {
"Invocation": [
{
"OssOutputDelivery": "oss://testBucket/testPrefix",
"InvocationStatus": "Running",
"Parameters": "{}",
"Timed": false,
"CommandDescription": "testDescription",
"Timeout": 60,
"InvokeInstances": {
"InvokeInstance": [
{
"Dropped": 0,
"InvocationStatus": "Success",
"InstanceId": "i-bp1i7gg30r52z2em****",
"Timed": false,
"InstanceInvokeStatus": "Finished",
"ExitCode": 0,
"ErrorInfo": "the specified instance does not exists",
"StartTime": "2019-12-20T06:15:55Z",
"Repeats": 0,
"OssOutputUri": "oss://testBucket/testPrefix/output.txt",
"OssOutputStatus": "Finished",
"OssOutputErrorCode": "CloudAssistant.UnsupportedInvocationStatus",
"OssOutputErrorInfo": "The invocation status does not support output delivery.",
"FinishTime": "2019-12-20T06:15:56Z",
"Output": "OutPutTestmsg",
"CreationTime": "2019-12-20T06:15:54Z",
"UpdateTime": "2020-01-19T09:15:47Z",
"ErrorCode": "InstanceNotExists",
"StopTime": "2020-01-19T09:15:47Z"
}
]
},
"CommandContent": "cnBtIC1xYSB8IGdyZXAgdnNm****",
"WorkingDir": "/home/",
"RepeatMode": "Once",
"InvokeStatus": "Finished",
"CommandType": "RunShellScript",
"Username": "test",
"ContainerId": "ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea****",
"ContainerName": "test-container",
"CreationTime": "2020-01-19T09:15:46Z",
"Frequency": "0 */20 * * * *",
"Launcher": "python3 -u {{ACS::ScriptFileName|Ext(\".py\")}}",
"CommandId": "c-hz0jdfwcsr****",
"CommandName": "CommandTestName",
"InvokeId": "t-hz0jdfwd9f****",
"TerminationMode": "ProcessTree",
"Tags": {
"Tag": [
{
"TagKey": "owner",
"TagValue": "zhangsan"
}
]
}
}
]
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | RegionId.ApiNotSupported | The api is not supported in this region. | The API operation cannot be called in the specified region. Check whether the specified RegionId parameter is valid. |
| 400 | NumberExceed.Tags | The Tags parameter number is exceed. | The number of tags exceeds the maximum limit. |
| 400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | The specified tag key already exists. Tag keys must be unique. |
| 400 | InvalidTagKey.Malformed | The specified Tag.n.Key is not valid. | The specified Tag.N.Key parameter is invalid. |
| 400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | The specified tag value is invalid. |
| 400 | MissingParameter.TagKey | You must specify Tag.N.Key. | The tag key is not specified. |
| 400 | InvalidParam.PageNumber | The specified parameter is invalid. | |
| 400 | InvalidParam.PageSize | The specified parameter is invalid. | |
| 400 | InvalidParameter.NextToken | The specified parameter NextToken is not valid. | The specified parameter NextToken is illegal. |
| 400 | InvalidParameter.MaxResults | The specified parameter MaxResults is not valid. | The specified parameter MaxResults is illegal. |
| 500 | InternalError.Dispatch | An error occurred when you dispatched the request. | An error occurred while the request is being sent. Try again later. |
| 403 | Operation.Forbidden | The operation is not permitted. | The operation is not supported. |
| 404 | InvalidRegionId.NotFound | The RegionId provided does not exist in our records. | Region information error |
| 404 | InvalidCommandId.NotFound | The specified commandId does not exist |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.