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 must check the actual execution results based on the return values of this operation.
-
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, which avoids frequent polling and improves efficiency.
-
When paged query the first page of results, set only
MaxResultsto limit the number of entries returned. TheNextTokenvalue in the response serves as the token for querying subsequent pages. When paged query subsequent pages, setNextTokento the value 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 aggregated status across multiple instances.DescribeInvocationResultsreturns only the individual execution status on each instance, without the aggregated status across multiple instances.
- When a single
RunCommand/InvokeCommandcall specifies one instance:DescribeInvocationsandDescribeInvocationResultsare largely interchangeable.
When you want to view the execution history of scheduled (periodic) tasks or tasks that run automatically at instance startup (
RepeatMode=Period, EveryReboot), onlyDescribeInvocationResultscan return historical execution records (you must specifyIncludeHistory=true).DescribeInvocationsreturns only the latest task status.When you want 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 resource group ID for command execution. After you specify this parameter, you must also specify ResourceGroupId when running the command. This parameter filters the corresponding command execution results. |
rg-bp67acfmxazb4p**** |
| RegionId |
string |
Yes |
地域 ID。您可以调用 DescribeRegions 查看最新的阿里云地域列表。 |
cn-hangzhou |
| 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 perform paging queries. |
1 |
| PageSize |
integer |
No |
Note
This parameter is about to be deprecated. Use NextToken and MaxResults to perform paging queries. |
10 |
| MaxResults |
integer |
No |
The maximum number of entries per page for a paged 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 number of resources with the specified tag cannot exceed 1,000. If you use multiple tags to filter resources, the number of resources with all specified tags attached cannot exceed 1,000. If the resource count exceeds 1,000, call ListTagResources 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 |
OSS delivery configuration for command execution output. |
oss://testBucket/testPrefix |
| InvocationStatus |
string |
The overall execution status of the command. This overall status is determined by the combined execution statuses of all instances involved in this invocation. Possible values are as follows:
Note
The |
Running |
| Parameters |
string |
Custom parameters in the command. |
{} |
| Timed |
boolean |
Indicates whether the queried command will be automatically executed in the future. |
false |
| CommandDescription |
string |
Command description. |
testDescription |
| Timeout |
integer |
The maximum timeout duration, in seconds, for the command you created when it is executed on an ECS instance. A timeout occurs when the command you created cannot be run for any reason. After the timeout, the command process is forcibly stopped, meaning the command's PID is canceled. |
60 |
| InvokeInstances |
object |
||
| InvokeInstance |
array<object> |
The type of the target instance set for execution. |
|
|
object |
The list of execution statuses. |
||
| Dropped |
integer |
The length of text truncated and discarded from the Output field when it exceeds 24 KB. |
0 |
| InvocationStatus |
string |
The command execution status on a single instance. Possible values:
|
Success |
| InstanceId |
string |
Instance ID. |
i-bp1i7gg30r52z2em**** |
| Timed |
boolean |
Indicates whether the queried command will be automatically executed in the future. |
false |
| InstanceInvokeStatus |
string |
The command execution progress status on a single instance. Note
We do not recommend that you view this return value. We recommend that you view the return value of |
Finished |
| ExitCode |
integer |
The exit code of the command process. Possible values:
|
0 |
| ErrorInfo |
string |
Details about why the command failed to be sent or executed. Possible values:
|
the specified instance does not exists |
| StartTime |
string |
The time when the command started executing on the instance. |
2019-12-20T06:15:55Z |
| Repeats |
integer |
The number of times the command was executed on this instance.
|
0 |
| OssOutputUri |
string |
The URI of the file in OSS to which the command Outputs are delivered. This field is an empty string if delivery is in progress or has failed. |
oss://testBucket/testPrefix/output.txt |
| OssOutputStatus |
string |
The delivery status of the command Outputs. Valid values:
|
Finished |
| OssOutputErrorCode |
string |
The error code returned when delivery fails. This value is returned only when OssOutputStatus is Failed.
|
CloudAssistant.UnsupportedInvocationStatus |
| OssOutputErrorInfo |
string |
Error Details when delivery fails. 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 output information of the command.
|
OutPutTestmsg |
| CreationTime |
string |
The start time of command execution. |
2019-12-20T06:15:54Z |
| UpdateTime |
string |
The update time of the command status. |
2020-01-19T09:15:47Z |
| ErrorCode |
string |
The error code indicating why the command failed to be delivered or executed. Possible values:
|
InstanceNotExists |
| StopTime |
string |
If |
2020-01-19T09:15:47Z |
| CommandContent |
string |
Command content.
|
cnBtIC1xYSB8IGdyZXAgdnNm**** |
| WorkingDir |
string |
The path where the command is executed. |
/home/ |
| RepeatMode |
string |
The mode in which the command is executed. Possible values:
|
Once |
| InvokeStatus |
string |
The overall execution status of the command. Note
We do not recommend checking this return value. We recommend that you check the return value of |
Finished |
| CommandType |
string |
The command type. |
RunShellScript |
| Username |
string |
The username used to execute the command on the ECS instance. |
test |
| ContainerId |
string |
The container ID. |
ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea**** |
| ContainerName |
string |
The container name. |
test-container |
| CreationTime |
string |
The Creation Time of the Job. |
2020-01-19T09:15:46Z |
| Frequency |
string |
The running time of the scheduled command. |
0 */20 * * * * |
| Launcher |
string |
The launcher for script execution. The length cannot exceed 1 KB. |
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 stopping a Job (either manually or due to a timeout interruption). Possible 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 |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.