Running a Cloud Assistant command in the ECS console is similar to running a command after logging on to an instance. The command succeeds only if all conditions are met. After you run a command, you should view its result and status to ensure that the target operation is complete. If the execution fails, you can use the error messages to find and fix the problem.
Background information
A command may show different execution statuses and results if an ECS instance lacks dependencies, has network issues, contains command semantic errors, fails script debugging, or has an abnormal status. You can view error messages in the execution results from the console or using an API to diagnose and fix the problem.
View execution results
View results in the console
- ECS console - Storage Capacity Units
In the top navigation bar, select the region and resource group of the resource that you want to manage.
On the Command Execution Results tab, you can view the command execution results.
If the command is successful, you can view the output in the execution results.
Find the command execution result with an Execution Status of Execution Succeeded.
In the Actions column, click View.
On the Instance List page, you can view the command execution results on the Execution Finished tab.
If the command fails, you can view the error message in the execution results and use the message to diagnose and fix the problem.
Find the command execution result with an Execution Status of Execution Failed.
In the Actions column, click View.
On the Execution Failed tab of the Instance List page, view the error message.
For information about common error messages and recommended solutions, see Common execution failure errors and recommended solutions.
You can view the output of a scheduled task.
Find the command execution result with an Execution Status of Scheduled.
In the Actions column, click View.
On the Instance List page, you can view the command execution result.
View results using Alibaba Cloud CLI
For more information about how to use Alibaba Cloud CLI, see Manage Alibaba Cloud resources using Alibaba Cloud CLI.
Obtain the command execution ID (InvokeId) from the response of the RunCommand or InvokeCommand operation.
Enter the InvokeId and the region ID (RegionId) of the ECS instance to query the command execution result. The following example uses the China (Shanghai) region. For the IDs of other regions, see Regions and zones.
Call the
DescribeInvocations
operation to view the execution status of the command.aliyun ecs DescribeInvocations --RegionId cn-shanghai --InvokeId t-sh054h*****
Call the
DescribeInvocationResults
operation to view the execution result of the command.aliyun ecs DescribeInvocationResults --RegionId cn-shanghai --InvokeId t-sh054h******
View results using an API
Obtain the command execution ID (InvokeId) from the response of the RunCommand or InvokeCommand operation.
In the DescribeInvocations or DescribeInvocationResults operation, enter the InvokeId and the region ID of the ECS instance to query the command execution result.
Common execution failure errors and recommended solutions
Common errors
Error code | Error message | Recommended solution |
InstanceNotRunning | The instance was not in the running state when the task was created. | Make sure that the instance is running. |
InstanceRestarted | The instance was restarted during task execution. | Do not restart the instance during task execution. |
ClientNotRunning | The Cloud Assistant Agent is not running. | The Cloud Assistant Agent is stopped or not installed. Start or install the Cloud Assistant Agent.
Note If the Cloud Assistant Agent still fails to start, you can reinstall it. For more information, see Install the Cloud Assistant Agent. |
ClientNetworkBlocked | The network environment of the instance is abnormal. |
Note
|
SecurityGroupRuleDenied | A security group rule denies access to the Cloud Assistant service. |
|
ClientNotResponse | The Cloud Assistant Agent did not respond. | Check the logs of the Cloud Assistant Agent.
|
ClientNeedUpgrade | The Cloud Assistant Agent needs to be upgraded to support the specified feature. |
|
ClientNotOnline | The Cloud Assistant Agent is not connected to the server. | Restart the Cloud Assistant Agent. For more information, see Stop and uninstall the Cloud Assistant Agent. |
DeliveryTimeout | The Cloud Assistant server failed to send the task to the Cloud Assistant Agent. | The Cloud Assistant command has not been sent to the instance. Run the command again. |
ExecutionTimeout | The command execution timed out. | Extend the command execution timeout period as needed.
|
ExecutionException | An exception occurred during command execution. | View the detailed error message in the ErrorInfo field. |
ExitCodeNonzero | The command finished executing, but the exit code of the command process is not 0. | Check the script content and the output of the command. |
ClientRestarted | The task was interrupted because the Cloud Assistant Agent was restarted. | Run the command again after the restart is complete. You can view the running status of the Cloud Assistant Agent in the Cloud Assistant console or by calling the DescribeCloudAssistantStatus operation. |
InstanceReleased | The instance was released during command execution. | The command cannot be executed because the instance was released during execution. |
DirectoryNotExists | The specified working directory does not exist in the instance. | Create the specified working directory in the instance, and then run the command. |
Running commands
Error code | Error message | Recommended solution |
ClientIsUpgrading | The Cloud Assistant Agent is being upgraded. | Run the command again after the upgrade is complete. You can view the running status of the Cloud Assistant Agent in the Cloud Assistant console or by calling the DescribeCloudAssistantStatus operation. |
InstanceDeregistered | The managed instance has been unregistered. | The command cannot be executed because the managed instance was already unregistered. |
InvalidSystemBuiltInParameter | The built-in environment parameter is invalid. | The specified built-in environment parameter is not supported. For more information about built-in environment parameters, see the description of the |
DefaultWorkingDirectoryNotAvailable | The default working directory in the instance is not available. | Check the default working directory in the instance:
You can also specify a working directory when you run the command. You can specify the directory in the Cloud Assistant console or using the |
CommandNotApplicable | The command type is not applicable to the specified instance. | The operating systems supported by each command type are as follows:
|
InvalidCommandText | The command content is invalid. | Check the command content. The content can be in plaintext or Base64-encoded. |
CommandContentDecodeError | Failed to decode the command content. | If the command content is Base64-encoded, check whether the encoding is correct. |
AccountNotExists | The specified user does not exist in the instance. | Create the specified user in the instance before you run the command.
You can also specify another existing user to run the command. You can specify the user in the Cloud Assistant console or using the |
Running scheduled commands
Error code | Error message | Recommended solution |
BadCronExpression | The specified cron expression is invalid. | Modify the cron expression. For more information, see Clock-based scheduling. |
CronExpressionExpired | The cron expression has expired. The corresponding scheduled task will not be executed. | Do not specify an expired cron expression when you run the command. |
InvalidGMTOffsetForTimezone | The format of the GMT offset time zone specified in the cron expression is invalid. | Check the format of the GMT offset time zone. The supported GMT range is GMT-12:59 to GMT+14:59. The minute can be any value from 0 to 59. Leading zeros are not supported for the hour. |
InvalidGMTOffsetHourForTimezone | The GMT offset hour value specified in the cron expression is invalid. | Check the hour value of the GMT offset time zone. The supported GMT range is GMT-12:59 to GMT+14:59. Leading zeros are not supported for the hour. |
InvalidGMTOffsetMinuteForTimezone | The GMT offset minute value specified in the cron expression is invalid. | Check the minute value of the GMT offset time zone. The minute can be any value from 0 to 59. |
TimezoneInformationCorrupt | The Cloud Assistant Agent cannot parse the time zone information because the time zone file is corrupted or for other reasons. |
Note If the corresponding time zone file does not exist, create the correct time zone file before you run the command. |
InvalidRateExpression | The Rate expression is invalid. | Modify the Rate expression. For more information, see Fixed interval execution. |
RateFrequencyTooLarge | The scheduled execution frequency specified in the Rate expression is too high. | The scheduled execution frequency cannot be longer than 7 days. |
InvalidAtExpression | The timestamp (At expression) is invalid. | Modify the timestamp. For more information, see Run a command only once at a specified time. |
AtExpressionExpired | The timestamp (At expression) has expired. The corresponding scheduled task will not be executed. | Do not specify an expired timestamp when you run the command. |
Running commands in containers
Error code | Error message | Recommended solution |
InvalidContainerName | The container name is invalid. | The container name must start with a digit or a letter. It can contain only digits, uppercase and lowercase letters, periods (.), underscores (_), and hyphens (-). The name cannot exceed 255 characters in length. |
UnsupportedContainerRuntime | The container runtime included in the container ID is not supported. | Only containers that are managed by Kubernetes through the Container Runtime Interface (CRI) and run on docker, containerd, or cri-o container runtimes are supported. |
InvalidContainerId | The container ID is invalid. | Only 64-bit hexadecimal strings are supported. You can add the |
ContainerConnectFailed | Cannot connect to the container. | Check whether the container is running. You can use
|
ContainerStateAbnormal | The container status is abnormal. | Check the container status. You can run commands using Cloud Assistant only on running containers. You can use |
ContainerNotFound | The container does not exist. | Check whether a container with the specified name or ID exists. Method 1: Use kubectl
Method 2: Use the Cloud Assistant Agent
For more information, see Use Cloud Assistant to run commands in a container. |
ContainerNameDuplicated | The node has containers with the same name. The container on which to run the command cannot be identified. |
|
ContainerNameAndIdNotMatch | The container ID and container name do not match. | The specified container ID and container name do not correspond to the same container. Check whether the container ID and container name are correct. |
Running commands as a non-default user (System) on a Windows instance
The following issues may occur when you run commands as a non-default user (not System) on a Windows instance.
Error code | Error message | Recommended solution |
UserOrPasswordInvalid | The username or password is incorrect. | The username or the password for the user is incorrect. For more information about usernames and passwords, see Encrypted parameters and Set a regular user to run Cloud Assistant commands. |
QueryParameterStoreFailed | Failed to pull parameters from Parameter Store. | Check whether the corresponding password information exists in the parameter store of CloudOps Orchestration Service. For more information, see Encrypted parameters. |
InstanceRoleInvalid | The instance role is not granted to the instance. | Call the DescribeInstanceRamRole operation to check whether the corresponding RAM role exists on the instance. |
Stopping commands
Error code | Error message | Recommended solution |
TerminationException | Failed to stop the task. | View the detailed error message in the ErrorInfo field, or retry stopping the task. |
Sending files
Error code | Error message | Recommended solution |
FileAlreadyExists | A file with the same name exists in the same path. | You can resolve this issue in one of the following ways:
Change the destination path or the name of the file that you want to send. |
FileNameInvalid | The file name is invalid. | Adjust the file name to comply with the file naming conventions of the Windows or Linux operating system.
|
FilePathInvalid | The file path is invalid. | Adjust the file path to comply with the file path conventions of the Windows or Linux operating system.
|
FileAuthorityInvalid | The file permissions are invalid. | Adjust the file permissions. This setting takes effect only on Linux instances and is configured in the same way as the chmod command. |
UserGroupNotExists | The specified user group does not exist in the instance. | The default user group is root. Create the corresponding user group in the Linux instance. Example command: |
FAQ
Q: When I run a PowerShell script on a Windows server using Cloud Assistant, the Chinese characters in the output are garbled. Why does this happen and how can I fix it?
A: This is because the default environment that Cloud Assistant uses to execute PowerShell scripts does not use UTF-8 encoding to process the output, resulting in an encoding mismatch when the script outputs non-ASCII characters, such as Chinese characters, which causes the control
Garbled text appears because the platform cannot correctly parse the content.
There are two solutions:
Modify the script content: Add a line of code at the beginning of the script file to force the output encoding to UTF-8.
Add the following code to the beginning of the PowerShell script:
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 # --- Original script below --- Write-Output "Testing Chinese output..."
Modify the bootstrap program: In the advanced options of Cloud Assistant, modify the underlying command that runs the script to automatically set the encoding before the script runs.
In the Cloud Assistant command's Bootstrap Program field, enter the following code:
powershell -command $currentCulture=Get-Culture;if($currentCulture.LCID -eq 1033){[Console]::OutputEncoding=[System.Text.Encoding]::UTF8};{{ACS::ScriptFileName|Ext(.ps1)}};exit $LastExitCode
All PowerShell scripts run in this task will automatically apply UTF-8 encoding. You do not need to modify the script files individually.