呼叫 DescribeInvocationResults 查看一條或多條雲端助手命令的執行結果,即在 ECS 執行個體中的實際執行結果。
介面說明
介面說明
-
當您執行命令後,不代表命令一定成功執行,並且一定有預期的命令效果。您需要透過本介面查看實際的具體執行結果,以實際輸出結果為準。
-
您可以查詢最近 30 天的執行資訊,執行資訊的保留上限為 1 萬條。
-
您可以透過雲端助手任務狀態事件訂閱的方式,透過事件取得任務結果,避免頻繁輪詢,用以提升效率。
-
分頁查詢首頁時,僅需設定
MaxResults以限制返回資訊的條目數,返回結果中的NextToken將作為查詢後續頁的憑證。查詢後續頁時,將NextToken參數設定為上一次返回結果中取得到的NextToken作為查詢憑證,並設定MaxResults限制返回條目數。 -
DescribeInvocations和DescribeInvocationResults差異點:- 當一次
RunCommand/InvokeCommand呼叫指定有多個執行個體時:使用
DescribeInvocations可以獲得任務在各個執行個體上的執行狀態、多個執行個體任務狀態的聚合狀態;使用
DescribeInvocationResults僅能獲得各個執行個體上的單獨的執行狀態,不包含多執行個體的聚合狀態;
- 當一次
RunCommand/InvokeCommand呼叫指定有一個執行個體時:DescribeInvocations與DescribeInvocationResults區別不大,完全可以互相替換。
當需要查看定時性(週期性)任務、開機自動執行任務(
RepeatMode=Period, EveryReboot)的每一次執行情況時,僅能用DescribeInvocationResults可以查詢獲得執行的過往歷史記錄(需指定IncludeHistory=true),而DescribeInvocations僅支援返回最新的任務狀態。當需要查看命令的內容、參數時,僅有
DescribeInvocations返回CommandContent。
- 當一次
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
|
操作 |
存取層級 |
資源類型 |
條件關鍵字 |
關聯操作 |
|
ecs:DescribeInvocationResults |
get |
Command
Instance
|
無 | 無 |
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| RegionId |
string |
是 |
地域 ID。您可以呼叫 DescribeRegions 查看最新的阿里雲地域列表。 |
cn-hangzhou |
| ResourceGroupId |
string |
否 |
命令執行的資源群組 ID。傳入該參數後,需要在執行命令時指定 ResourceGroupId,支援篩選出對應的命令執行結果。 |
rg-bp67acfmxazb4p**** |
| InvokeId |
string |
否 |
地域 ID。您可以呼叫 DescribeRegions 查看最新的阿里雲地域列表。 |
t-hz0jdfwd9f**** |
| InstanceId |
string |
否 |
命令執行 ID。您可以透過介面 DescribeInvocations 查詢 InvokeId。 |
i-bp1i7gg30r52z2em**** |
| CommandId |
string |
否 |
執行個體 ID。 |
c-hz0jdfwcsr**** |
| InvokeRecordStatus |
string |
否 |
命令 ID。 |
Running |
| IncludeHistory |
boolean |
否 |
命令執行狀態。取值範圍:
|
false |
| ContentEncoding |
string |
否 |
是否返回命令定時執行的歷史記錄。取值範圍:
預設值為 false。 |
PlainText |
| PageNumber |
integer |
否 |
設定返回資料中
預設值為 Base64。 |
1 |
| PageSize |
integer |
否 |
說明
該參數即將下線,建議您使用 NextToken 與 MaxResults 完成分頁查詢操作。 |
1 |
| MaxResults |
integer |
否 |
說明
該參數即將下線,建議您使用 NextToken 與 MaxResults 完成分頁查詢操作。 |
10 |
| NextToken |
string |
否 |
分頁查詢時每頁的最大條目數。 最大值為 50。 預設值為 10。 |
AAAAAdDWBF2 |
| Tag |
array<object> |
否 |
查詢憑證(Token),取值為上一次 API 呼叫返回的 NextToken 參數值。 |
|
|
object |
否 |
標籤列表。 |
||
| Value |
string |
否 |
命令執行的標籤值。N 的取值範圍為 1~20。該值可以為空字串。 最多支援 128 個字元,不能包含 |
TestValue |
| Key |
string |
否 |
命令執行的標籤鍵。N 的取值範圍為 1~20。一旦傳入該值,則不允許為空字串。 使用一個標籤過濾資源,查詢到該標籤下的資源數量不能超過 1000 個;使用多個標籤過濾資源,查詢到同時繫結了多個標籤的資源數量不能超過 1000 個。如果資源數量超過 1000 個,您需要使用 ListTagResources 介面進行查詢。 最多支援 64 個字元,不能以 |
TestKey |
|
否 |
標籤列表。 |
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
|
object |
|||
| RequestId |
string |
請求 ID。 |
473469C7-AA6F-4DC5-B3DB-A3DC0DE***** |
| Invocation |
object |
命令執行結果的集合。 |
|
| PageSize |
integer |
分頁查詢時設定的每頁行數。 |
1 |
| PageNumber |
integer |
目前頁碼。 |
1 |
| TotalCount |
integer |
命令總個數。 |
1 |
| NextToken |
string |
本次呼叫返回的查詢憑證值。 |
AAAAAdDWBF2 |
| InvocationResults |
object |
||
| InvocationResult |
array<object> |
命令執行結果集。 |
|
|
array<object> |
|||
| Dropped |
integer |
|
0 |
| OssOutputDelivery |
string |
命令執行 Output OSS 投遞配置。 |
oss://testBucket/testPrefix |
| InvocationStatus |
string |
單台執行個體的命令進度狀態,可能值:
|
Success |
| InstanceId |
string |
執行個體 ID。 |
i-bp1i7gg30r52z2em**** |
| ExitCode |
integer |
命令的退出碼。
|
0 |
| ErrorInfo |
string |
命令的下發失敗或執行失敗原因的詳情,可能值:
|
the specified instance does not exists |
| StartTime |
string |
命令在執行個體中開始執行的時間。 |
2019-12-20T06:15:55Z |
| Repeats |
integer |
命令在該執行個體上執行的次數。
|
0 |
| InvokeRecordStatus |
string |
命令執行狀態。可能值:
|
Running |
| FinishedTime |
string |
命令執行的完成時間。如果命令執行出現逾時情況,命令執行的完成時間以 |
2019-12-20T06:15:56Z |
| OssOutputUri |
string |
命令執行 Output 投遞到 OSS 的檔案 URI 位址,當投遞失敗/投遞中時該欄位為空字串。 |
oss://testBucket/testPrefix/output.txt |
| OssOutputStatus |
string |
命令執行 Output 投遞狀態。列舉值:
|
Finished |
| OssOutputErrorCode |
string |
投遞失敗時的錯誤碼,僅在 OssOutputStatus 為 Failed 時返回。 取值範圍:
|
CloudAssistant.UnsupportedInvocationStatus |
| OssOutputErrorInfo |
string |
投遞失敗時的錯誤詳情,僅在 OssOutputStatus 為 Failed 時返回。 |
The invocation status does not support output delivery. |
| Username |
string |
在 ECS 執行個體中執行命令的使用者名稱。 |
test |
| ContainerId |
string |
容器 ID。 |
ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea**** |
| ContainerName |
string |
容器名稱。 |
test-container |
| Output |
string |
命令執行後的輸出資訊。
|
MTU6MzA6MDEK |
| Launcher |
string |
指令碼執行的引導程式。長度不能超過 1 KB。 |
python3 -u {{ACS::ScriptFileName|Ext(".py")}} |
| CommandId |
string |
命令 ID。 |
c-hz0jdfwcsr**** |
| ErrorCode |
string |
命令下發失敗或執行失敗原因的代碼,可能值:
|
InstanceNotExists |
| InvokeId |
string |
命令執行 ID。 |
t-hz0jdfwd9f**** |
| TerminationMode |
string |
停止任務(手動停止或執行逾時打斷)時的模式。可能值:
|
ProcessTree |
| Tags |
object |
||
| Tag |
array<object> |
命令執行的標籤資訊。 |
|
|
object |
命令執行的標籤資訊。 |
||
| TagKey |
string |
命令執行的標籤鍵。 |
owner |
| TagValue |
string |
命令執行的標籤值。 |
zhangsan |
| StopTime |
string |
若呼叫了 |
2020-01-19T09:15:47Z |
樣本
正常返回樣本
JSON格式
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE*****",
"Invocation": {
"PageSize": 1,
"PageNumber": 1,
"TotalCount": 1,
"NextToken": "AAAAAdDWBF2",
"InvocationResults": {
"InvocationResult": [
{
"Dropped": 0,
"OssOutputDelivery": "oss://testBucket/testPrefix",
"InvocationStatus": "Success",
"InstanceId": "i-bp1i7gg30r52z2em****",
"ExitCode": 0,
"ErrorInfo": "the specified instance does not exists",
"StartTime": "2019-12-20T06:15:55Z",
"Repeats": 0,
"InvokeRecordStatus": "Running",
"FinishedTime": "2019-12-20T06:15:56Z",
"OssOutputUri": "oss://testBucket/testPrefix/output.txt",
"OssOutputStatus": "Finished",
"OssOutputErrorCode": "CloudAssistant.UnsupportedInvocationStatus",
"OssOutputErrorInfo": "The invocation status does not support output delivery.",
"Username": "test",
"ContainerId": "ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea****",
"ContainerName": "test-container",
"Output": "MTU6MzA6MDEK",
"Launcher": "python3 -u {{ACS::ScriptFileName|Ext(\".py\")}}",
"CommandId": "c-hz0jdfwcsr****",
"ErrorCode": "InstanceNotExists",
"InvokeId": "t-hz0jdfwd9f****",
"TerminationMode": "ProcessTree",
"Tags": {
"Tag": [
{
"TagKey": "owner",
"TagValue": "zhangsan"
}
]
},
"StopTime": "2020-01-19T09:15:47Z"
}
]
}
}
}
錯誤碼
|
HTTP status code |
錯誤碼 |
錯誤資訊 |
描述 |
|---|---|---|---|
| 400 | RegionId.ApiNotSupported | The api is not supported in this region. | |
| 400 | NumberExceed.Tags | The Tags parameter number is exceed. | |
| 400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | |
| 400 | InvalidTagKey.Malformed | The specified Tag.n.Key is not valid. | |
| 400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | |
| 400 | MissingParameter.TagKey | You must specify Tag.N.Key. | |
| 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. | |
| 400 | InvalidParameter.MaxResults | The specified parameter MaxResults is not valid. | |
| 500 | InternalError.Dispatch | An error occurred when you dispatched the request. | |
| 500 | ServiceUnavailable | The request has failed due to a temporary failure of the server. | |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 403 | Operation.Forbidden | The operation is not permitted. | |
| 404 | InvalidRegionId.NotFound | The RegionId provided does not exist in our records. |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。