All Products
Search
Document Center

Elastic Compute Service:DescribeInvocationResults

Last Updated:Jul 09, 2024

Queries the execution results of one or more Cloud Assistant commands on Elastic Compute Service (ECS) instances.

Operation description

Usage notes

  • After you run a command, the command may fail to run or may return unexpected results. You can call this operation to query the execution results.

  • You can query information about command executions within the last four weeks. Up to 100,000 pieces of execution information can be retained.

  • You can subscribe to Cloud Assistant task status events to obtain command execution results from the events. This helps you reduce the number of times to poll API operations and improve efficiency.

  • You can use one of the following methods to check the responses:

    • Method 1: During a paged query, when you call the DescribeInvocationResults operation to retrieve the first page of results, set MaxResults to specify the maximum number of entries to return in the call. The return value of NextToken is a pagination token, which can be used in the next request to retrieve a new page of results. When you call the DescribeInvocationResults operation to retrieve a new page of results, set NextToken to the NextToken value returned in the previous call and set MaxResults to specify the maximum number of entries to return in this call.
    • Method 2: Use PageSize to specify the number of entries per page, and then use PageNumber to specify the page number. You can use only one of the preceding methods. If you specify MaxResults or NextToken, the PageSize and PageNumber request parameters do not take effect and the TotalCount response parameter is invalid.
  • Comparison between the DescribeInvocations and DescribeInvocationResults operations:

    • Scenario in which the RunCommand or InvokeCommand operation is called to run a Cloud Assistant command on multiple instances:

      • The DescribeInvocations operation queries the execution status of the command on each instance and the overall execution status of the command on all instances.
      • The DescribeInvocationResults operation queries only the execution status of the command on each instance.
    • Scenario in which the RunCommand or InvokeCommand operation is called to run a Cloud Assistant command on a single instance:

      • The DescribeInvocations operation is equivalent to the DescribeInvocationResults operation.
    • If you want to query the status of each execution for a scheduled (recurring) task or a task that is automatically executed on instance startup (RepeatMode is set to Period or EveryReboot), you can call only the DescribeInvocationResults operation and must set IncludeHistory to true. The DescribeInvocations operation queries only the most recent execution status of the command.

    • If you want to view the command content and parameters, you can call only the DescribeInvocations operation and check the CommandContent value in the response.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the command. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
ResourceGroupIdstringNo

The ID of the resource group. After you set this parameter, command execution results in the specified resource group are queried.

rg-bp67acfmxazb4p****
InvokeIdstringNo

The ID of the command task. You can call the DescribeInvocations operation to query the IDs of all command tasks.

t-hz0jdfwd9f****
InstanceIdstringNo

The ID of the instance.

i-bp1i7gg30r52z2em****
CommandIdstringNo

The ID of the command.

c-hz0jdfwcsr****
InvokeRecordStatusstringNo

The execution status of the command task. Valid values:

  • Running:

    • Scheduled task: Before you stop the scheduled execution of the command, the execution state is always Running.
    • One-time task: If the command is being run on instances, the execution state is Running.
  • Finished:

    • Scheduled task: The execution state can never be Finished.
    • One-time task: The execution is complete on all instances, or the execution is stopped on some instances and is complete on the other instances.
  • Success:

    • One-time task: The execution is complete, and the exit code is 0.
    • Scheduled task: The last execution is complete, the exit code is 0, and the specified period ends.
  • Failed:

    • Scheduled task: The execution state can never be Failed.
    • One-time task: The execution fails on all instances.
  • PartialFailed:

    • Scheduled task: The execution state can never be PartialFailed.
    • One-time task: The execution fails on some instances.
  • Stopped: The task is stopped.

  • Stopping: The task is being stopped.

Running
IncludeHistorybooleanNo

Specifies whether to return the results of historical scheduled executions. Valid values:

  • true: returns the results of historical scheduled executions. If you set this parameter to true, you must set InvokeId to the ID of a task that is run on a schedule (RepeatMode set to Period) or on each system startup (RepeatMode set to EveryReboot).
  • false: does not return the results of historical scheduled executions.

Default value: false.

false
ContentEncodingstringNo

The encoding mode of the CommandContent and Output values in the response. Valid values:

  • PlainText: returns the original command content and command output.
  • Base64: returns the Base64-encoded command content and command output.

Default value: Base64.

PlainText
PageNumberlongNo

The page number.

Pages start from page 1.

Default value: 1.

1
PageSizelongNo

The number of entries per page.

Valid values: 1 to 50.

Default value: 10.

1
MaxResultsintegerNo

The maximum number of entries per page.

Valid values: 1 to 50.

Default value: 10.

10
NextTokenstringNo

The pagination token that is used in the next request to retrieve a new page of results. You do not need to specify this parameter for the first request. You must specify the token that is obtained from the previous query as the value of NextToken.

AAAAAdDWBF2
Tagarray<object>No

The tags of the command task.

objectNo

The tag of the command task.

KeystringNo

The key of tag N of the command task. Valid values of N: 1 to 20. The tag key cannot be an empty string.

If a single tag is specified to query resources, up to 1,000 resources that have this tag added can be displayed in the response. If multiple tags are specified to query resources, up to 1,000 resources that have all these tags added can be displayed in the response. To query more than 1,000 resources that have specified tags added, call the ListTagResources operation.

The tag key can be up to 64 characters in length and cannot start with acs: or aliyun. It cannot contain http:// or https://.

TestKey
ValuestringNo

The value of tag N of the command task. 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 http:// or https://.

TestValue

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The ID of the request.

473469C7-AA6F-4DC5-B3DB-A3DC0DE*****
Invocationobject

Details about the execution results.

PageSizelong

The number of entries per page.

1
PageNumberlong

The page number.

1
TotalCountlong

The total number of the commands.

1
NextTokenstring

A pagination token. It can be used in the next request to retrieve a new page of results.

AAAAAdDWBF2
InvocationResultsarray<object>

The execution results.

object
InvocationStatusstring

The execution status on a single instance. Valid values:

  • Pending: The command is being verified or sent.

  • Invalid: The specified command type or parameter is invalid.

  • Aborted: The command failed to be sent to the instance. To send a command to an instance, make sure that the instance is in the Running state and the command can be sent to the instance within 1 minute.

  • Running: The command is being run on the instance.

  • Success:

    • One-time task: The execution was complete, and the exit code was 0.
    • Scheduled task: The last execution was complete, the exit code was 0, and the specified period ended.
  • Failed:

    • One-time task: The execution was complete, but the exit code was not 0.
    • Scheduled task: The last execution was complete, but the exit code was not 0. The specified period was about to end.
  • Error: The execution cannot proceed due to an exception.

  • Timeout: The execution timed out.

  • Cancelled: The execution was canceled before it started.

  • Stopping: The command task is being stopped.

  • Terminated: The execution was terminated before completion.

  • Scheduled:

    • One-time task: The execution state can never be Scheduled.
    • Scheduled task: The command is waiting to be run.
Success
Repeatsinteger

The number of times that the command was run on the instance.

  • If the command is set to run only once, the value is 0 or 1.
  • If the command is set to run on a schedule, the value is the number of times that the command has been run on the instance.
0
CommandIdstring

The command ID.

c-hz0jdfwcsr****
InstanceIdstring

The instance ID.

i-bp1i7gg30r52z2em****
Outputstring

The command output.

  • If ContentEncoding is set to PlainText in the request, the original command output is returned.
  • If ContentEncoding is set to Base64 in the request, the Base64-encoded command output is returned.
MTU6MzA6MDEK
Droppedinteger

The size of the Output text that was truncated and discarded because the Output value exceeded 24 KB in size.

0
StopTimestring

The time when the command task was stopped. If you call the StopInvocation operation to stop the command task, the value of this parameter is the time when the operation is called.

2020-01-19T09:15:47Z
ExitCodelong

The exit code of the command task.

  • For Linux instances, the value is the exit code of the shell command.
  • For Windows instances, the value is the exit code of the batch or PowerShell command.
0
StartTimestring

The time when the command started to be run on the instance.

2019-12-20T06:15:55Z
ErrorInfostring

The error message returned when the command failed to be sent or run. Valid values:

  • If this parameter is empty, the command was run as expected.
  • the specified instance does not exists
  • the instance has released when create task
  • the instance is not running when create task
  • the command is not applicable
  • the specified account does not exists
  • the specified directory does not exists
  • the cron job expression is invalid
  • the aliyun service is not running on the instance
  • the aliyun service in the instance does not response
  • the aliyun service in the instance is upgrading now
  • the aliyun service in the instance need upgrade
  • the command delivery has been timeout
  • the command execution has been timeout
  • the command execution got an exception
  • the command execution has been interrupted
  • the command execution exit code is not zero
  • the specified instance has been released
the specified instance does not exists
ErrorCodestring

The error code returned when the command failed to be sent or run. Valid values:

  • If this parameter is empty, the command was run as expected.
  • InstanceNotExists: The specified instance did not exist or was released.
  • InstanceReleased: The instance was released while the command was being run.
  • InstanceNotRunning: The instance was not running while the command was being run.
  • CommandNotApplicable: The command was inapplicable to the specified instance.
  • AccountNotExists: The username specified to run the command did not exist.
  • DirectoryNotExists: The specified directory did not exist.
  • BadCronExpression: The specified cron expression for the execution schedule was invalid.
  • ClientNotRunning: Cloud Assistant Agent was not running.
  • ClientNotResponse: Cloud Assistant Agent did not respond.
  • ClientIsUpgrading: Cloud Assistant Agent was being upgraded.
  • ClientNeedUpgrade: Cloud Assistant Agent needed to be upgraded.
  • DeliveryTimeout: The request to send the command timed out.
  • ExecutionTimeout: The execution timed out.
  • ExecutionException: An exception occurred while the command was being run.
  • ExecutionInterrupted: The execution was interrupted.
  • ExitCodeNonzero: The execution was complete, but the exit code was not 0.
  • SecurityGroupRuleDenied: Access to Cloud Assistant was denied by security group rules.
InstanceNotExists
FinishedTimestring

The time when the command task was completed. If the command task times out, the end time is equal to the start time of the command task specified by StartTime plus the timeout period specified by Timeout.

2019-12-20T06:15:56Z
InvokeIdstring

The command task ID.

t-hz0jdfwd9f****
InvokeRecordStatusstring

The execution status of the command. Valid values:

  • Running:

    • Scheduled task: Before you stop the scheduled execution of the command, the execution state is always Running.
    • One-time task: If the command is being run on instances, the execution state is Running.
  • Finished:

    • Scheduled task: The execution state can never be Finished.
    • One-time task: The execution was complete on all instances, or the execution was stopped on some instances and was complete on the other instances.
  • Failed:

    • Scheduled task: The execution state can never be Failed.
    • One-time task: The execution failed on all instances.
  • PartialFailed:

    • Scheduled task: The execution state can never be PartialFailed.
    • One-time task: The execution failed on some instances.
  • Stopped: The task was stopped.

  • Stopping: The task is being stopped.

Running
Usernamestring

The username used to run the command on the instance.

root
ContainerIdstring

The container ID.

ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea****
ContainerNamestring

The container name.

test-container
TerminationModestring

Indicates how the command task is stopped when a command execution is manually stopped or times out. Valid values:

  • Process: The process of the command is stopped.
  • ProcessTree: The process tree of the command is stopped. In this case, the process of the command and all subprocesses are stopped.
ProcessTree
Tagsarray<object>

The tags of the command task.

object

The tag of the command task.

TagKeystring

The tag key of the command task.

owner
TagValuestring

The tag value of the command task.

zhangsan

Examples

Sample success responses

JSONformat

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE*****",
  "Invocation": {
    "PageSize": 1,
    "PageNumber": 1,
    "TotalCount": 1,
    "NextToken": "AAAAAdDWBF2",
    "InvocationResults": {
      "InvocationResult": [
        {
          "InvocationStatus": "Success",
          "Repeats": 0,
          "CommandId": "c-hz0jdfwcsr****",
          "InstanceId": "i-bp1i7gg30r52z2em****",
          "Output": "MTU6MzA6MDEK",
          "Dropped": 0,
          "StopTime": "2020-01-19T09:15:47Z",
          "ExitCode": 0,
          "StartTime": "2019-12-20T06:15:55Z",
          "ErrorInfo": "the specified instance does not exists",
          "ErrorCode": "InstanceNotExists",
          "FinishedTime": "2019-12-20T06:15:56Z",
          "InvokeId": "t-hz0jdfwd9f****",
          "InvokeRecordStatus": "Running",
          "Username": "root",
          "ContainerId": "ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea****",
          "ContainerName": "test-container",
          "TerminationMode": "ProcessTree",
          "Tags": {
            "Tag": [
              {
                "TagKey": "owner",
                "TagValue": "zhangsan"
              }
            ]
          }
        }
      ]
    }
  }
}

Error codes

HTTP status codeError codeError messageDescription
400RegionId.ApiNotSupportedThe 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.
400NumberExceed.TagsThe Tags parameter number is exceed.The number of tags exceeds the maximum limit.
400Duplicate.TagKeyThe Tag.N.Key contain duplicate key.The specified tag key already exists. Tag keys must be unique.
400InvalidTagKey.MalformedThe specified Tag.n.Key is not valid.The specified Tag.N.Key parameter is invalid.
400InvalidTagValue.MalformedThe specified Tag.n.Value is not valid.The specified tag value is invalid.
400MissingParameter.TagKeyYou must specify Tag.N.Key.The tag key is not specified.
400InvalidParam.PageNumberThe specified parameter is invalid.The specified PageNumber parameter is invalid.
400InvalidParam.PageSizeThe specified parameter is invalid.The specified PageSize parameter is invalid.
400InvalidParameter.NextTokenThe specified parameter NextToken is not valid.The specified parameter NextToken is illegal.
400InvalidParameter.MaxResultsThe specified parameter MaxResults is not valid.The specified parameter MaxResults is illegal.
403Operation.ForbiddenThe operation is not permitted.The operation is not supported.
404InvalidRegionId.NotFoundThe RegionId provided does not exist in our records.The RegionId provided does not exist
500InternalError.DispatchAn error occurred when you dispatched the request.An error occurred while the request is being sent. Try again later.
500ServiceUnavailableThe request has failed due to a temporary failure of the server.-
500InternalErrorThe request processing has failed due to some unknown error.An internal error has occurred. Try again later.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-05-14The Error code has changed. The response structure of the API has changedView Change Details
2023-12-21The Error code has changed. The request parameters of the API has changed. The response structure of the API has changedView Change Details
2023-05-12The Error code has changedView Change Details
2022-02-25The Error code has changedView Change Details