Invoke the DescribeInvocations API to query the execution list and status of Cloud Assistant commands.
Operation description
-
After you execute a command, it does not necessarily mean that the command has run successfully or produced the expected effect. You must check the actual execution result through the API return value, and the actual output result takes precedence.
-
You can query execution information from the past four weeks, with a maximum retention limit of 100,000 records.
-
You can subscribe to Cloud Assistant task status event notifications to obtain task results via events, avoiding frequent polling and thereby improving efficiency.
-
When performing a paged query on the home page, you only need to set
MaxResultsto limit the number of returned entries. TheNextTokenin the return result serves as the credential for querying subsequent pages. When querying subsequent pages, set theNextTokenparameter to theNextTokenobtained from the previous response as the query credential, and also setMaxResultsto limit the number of returned entries. -
Differences between
DescribeInvocationsandDescribeInvocationResults:- When a single
RunCommand/InvokeCommandcall specifies multiple instances:DescribeInvocationsprovides the execution status on each instance as well as the aggregated status across all instances.DescribeInvocationResultsonly provides the individual execution status per instance, without the aggregated multi-instance status.
- When a single
RunCommand/InvokeCommandcall specifies only one instance:There is little difference between
DescribeInvocationsandDescribeInvocationResults, and they can be used interchangeably.
When you need to view the execution history of scheduled (periodic) tasks or tasks that automatically run at system startup (
RepeatMode=Period, EveryReboot), onlyDescribeInvocationResultscan retrieve historical execution records (by specifyingIncludeHistory=true). In contrast,DescribeInvocationsonly returns 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 view the latest Alibaba Cloud region list. |
cn-hangzhou |
| ResourceGroupId |
string |
No |
The resource group ID of the command execution. After you specify this parameter, you must also specify ResourceGroupId when executing the command. This enables filtering to retrieve the corresponding command execution results. |
rg-bp67acfmxazb4p**** |
| RegionId |
string |
Yes |
The Region ID. You can call DescribeRegions to view the latest Alibaba Cloud region list. |
cn-hangzhou |
| InvokeId |
string |
No |
The command execution ID. |
t-hz0jdfwd9f**** |
| CommandId |
string |
No |
The command ID. You can call the DescribeCommands API to query all available CommandId values. |
c-hz0jdfwcsr**** |
| CommandName |
string |
No |
The command name. If the |
CommandTestName |
| CommandType |
string |
No |
The command type. Valid values:
|
RunShellScript |
| Timed |
boolean |
No |
Indicates whether the queried command will be automatically executed in the future. Valid values:
Default value: false. |
true |
| InvokeStatus |
string |
No |
The overall execution status of the command. The overall status depends on the combined execution statuses of one or more instances involved in the command execution. Valid values:
|
Finished |
| InstanceId |
string |
No |
The instance ID. If you specify this parameter, all command execution records for this instance will be queried. |
i-bp1i7gg30r52z2em**** |
| ContentEncoding |
string |
No |
The codec for the
Default value: Base64. |
PlainText |
| IncludeOutput |
boolean |
No |
Indicates whether to return the command execution output in the results.
Default value: false. |
false |
| PageNumber |
integer |
No |
Note
This parameter will be unpublished soon. We recommend that you use NextToken and MaxResults to perform paged queries. |
1 |
| PageSize |
integer |
No |
Note
This parameter will be unpublished soon. We recommend that you use NextToken and MaxResults to perform paged query operations. |
10 |
| MaxResults |
integer |
No |
The maximum number of entries per page for paged queries. Maximum value: 50. Default value: 10. |
10 |
| NextToken |
string |
No |
The query credential (Token). Set this parameter to the NextToken value returned by the previous API call. |
AAAAAdDWBF2 |
| RepeatMode |
string |
No |
The execution mode of the command. This parameter does not take effect if the
Default value: empty, which indicates that all modes are queried. |
Once |
| Tag |
array<object> |
No |
The tag list. |
|
|
object |
No |
The tag list. |
||
| Value |
string |
No |
The tag value for command execution. Valid values for N are 1 to 20. This value can be an empty string. The value can contain up to 128 characters and must not contain |
TestValue |
| Key |
string |
No |
The tag key for command execution. Valid values for N are 1 to 20. If this value is specified, it cannot be an empty string. When you use one tag to filter resources, the number of resources under this tag cannot exceed 1,000. When you use multiple tags to filter resources, the number of resources bound to all specified tags simultaneously cannot exceed 1,000. If the number of resources exceeds 1,000, you must use the ListTagResources API to query them. The key can contain up to 64 characters, must not start with |
TestKey |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| PageSize |
integer |
Number of entries per page. |
10 |
| RequestId |
string |
Request ID. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
| PageNumber |
integer |
Page number of the query result. |
1 |
| TotalCount |
integer |
Total number of commands. |
1 |
| NextToken |
string |
Query credential value returned by this call. |
AAAAAdDWBF2 |
| Invocations |
object |
||
| Invocation |
array<object> |
An array composed of command execution records. |
|
|
array<object> |
Time of job creation. |
||
| 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.