

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# `AWSSupport-TroubleshootAWSBatchJob`
<a name="automation-aws-troubleshoot-aws-batch-job"></a>

 **描述** 

 `AWSSupport-TroubleshootAWSBatchJob`运行手册可帮助您解决导致 AWS Batch 任务无法从状态升级`RUNNABLE`到`STARTING`状态的问题。

 **如何工作？** 

此运行手册执行以下检查：
+ 如果计算环境处于`INVALID`或`DISABLED`状态。
+ 如果计算环境的`Max vCPU`参数足够大，足以容纳作业队列中的任务量。
+ 如果任务需要的 v CPUs 或内存资源超过计算环境的实例类型所能提供的资源。
+ 任务是否应在基于 GPU 的实例上运行，但计算环境未配置为使用基于 GPU 的实例。
+ 如果计算环境的 Auto Scaling 组无法启动实例。
+ 如果启动的实例可以加入底层的亚马逊弹性容器服务 (Amazon ECS) Service 集群；如果没有，则运行[AWSSupport-TroubleshootECSContainerInstance](https://docs.aws.amazon.com//systems-manager-automation-runbooks/latest/userguide/automation-aws-troubleshoot-ecs-container-instance.html)手册。
+ 如果有任何权限问题阻碍了运行作业所需的特定操作。

**重要**  
此 Runbook 必须与处于`RUNNABLE`状态的任务在同一个 AWS 区域启动。
可以为在亚马逊 ECS AWS Fargate 或亚马逊弹性计算云 (Amazon EC2) 实例上安排的 AWS Batch 任务启动本运行手册。如果在亚马逊 Elastic Kubernetes Service（亚马逊 EKS）上为 AWS Batch 任务启动自动化，则启动将停止。
如果实例可用于运行任务，但无法注册 Amazon ECS 集群，则此运行手册将启动`AWSSupport-TroubleshootECSContainerInstance`自动化运行手册以尝试确定原因。有关更多信息，请参阅[AWSSupport-TroubleshootECSContainerInstance](https://docs.aws.amazon.com//systems-manager-automation-runbooks/latest/userguide/automation-aws-troubleshoot-ecs-container-instance.html)运行手册。

 [运行此自动化（控制台）](https://console.aws.amazon.com/systems-manager/automation/execute/AWSSupport-TroubleshootAWSBatchJob) 

**文档类型**

自动化

**所有者**

Amazon

**平台**

Linux、macOS、Windows

**参数**
+ AutomationAssumeRole

  类型：字符串

  描述：（可选）允许 Systems Manager Automation 代表您执行操作 AWS Identity and Access Management (IAM) 角色的 Amazon 资源名称（ARN）。如果未指定角色，Systems Manager Automation 将使用启动此运行手册的用户的权限。
+ JobId

  类型：字符串

  描述：（必填）处于`RUNNABLE`状态的 AWS Batch Job 的 ID。

  允许的模式：`^[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}(:[0-9]+)?(#[0-9]+)?$`

**所需的 IAM 权限**

`AutomationAssumeRole` 参数需要执行以下操作才能成功使用运行手册。
+ `autoscaling:DescribeAutoScalingGroups`
+ `autoscaling:DescribeScalingActivities`
+ `batch:DescribeComputeEnvironments`
+ `batch:DescribeJobs`
+ `batch:DescribeJobQueues`
+ `batch:ListJobs`
+ `cloudtrail:LookupEvents`
+ `ec2:DescribeIamInstanceProfileAssociations`
+ `ec2:DescribeInstanceAttribute`
+ `ec2:DescribeInstances`
+ `ec2:DescribeInstanceTypeOfferings`
+ `ec2:DescribeInstanceTypes`
+ `ec2:DescribeNetworkAcls`
+ `ec2:DescribeRouteTables`
+ `ec2:DescribeSecurityGroups`
+ `ec2:DescribeSpotFleetInstances`
+ `ec2:DescribeSpotFleetRequests`
+ `ec2:DescribeSpotFleetRequestHistory`
+ `ec2:DescribeSubnets`
+ `ec2:DescribeVpcEndpoints`
+ `ec2:DescribeVpcs`
+ `ecs:DescribeClusters`
+ `ecs:DescribeContainerInstances`
+ `ecs:ListContainerInstances`
+ `iam:GetInstanceProfile`
+ `iam:GetRole`
+ `iam:ListRoles`
+ `iam:PassRole`
+ `iam:SimulateCustomPolicy`
+ `iam:SimulatePrincipalPolicy`
+ `ssm:DescribeAutomationExecutions`
+ `ssm:DescribeAutomationStepExecutions`
+ `ssm:GetAutomationExecution`
+ `ssm:StartAutomationExecution`
+ `sts:GetCallerIdentity`

 **说明** 

1. 在 AWS Systems Manager 控制台[AWSSupport-TroubleshootAWSBatchJob](https://console.aws.amazon.com/systems-manager/automation/execute/AWSSupport-TroubleshootAWSBatchJob)中导航到。

1. 选择 **Execute automation**（执行自动化）

1. 要输入参数，请输入内容：
   + **AutomationAssumeRole（可选）：**

      AWS Identity and Access Management (IAM) 角色的 Amazon 资源名称（ARN）允许 Systems Manager Automation 代表您执行操作。如果未指定角色，Systems Manager Automation 将使用启动此运行手册的用户的权限。
   + **JobId（必填）：**

     处于`RUNNABLE`状态的 AWS Batch Job 的 ID。  
![\[Input parameters form with AutomationAssumeRole and JobId fields for AWS Batch job configuration.\]](http://docs.aws.amazon.com/zh_cn/systems-manager-automation-runbooks/latest/userguide/images/awssupport-troubleshoot-aws-batch-job_input_paramters.png)

1. 选择**执行**。

1. 请注意，自动化已启动。

1. 文档将执行以下步骤：
   + **PreflightPermissionChecks:**

     对初始用户/角色执行预检 IAM 权限检查。如果缺少任何权限，则此步骤将提供全局输出部分中缺少的 API 操作。
   + **ProceedOnlyIfUserHasPermission:**

     根据您是否有权执行运行手册的所有必要操作进行分支。
   + **AWSBatchJobEvaluation:**

     对 AWS Batch Job 执行检查，验证其存在且处于`RUNNABLE`状态。
   + **ProceedOnlyIfBatchJobExistsAndIsinRunnable州：**

     根据任务是否存在以及是否处于`RUNNABLE`状态进行分支。
   + **BatchComputeEnvironmentEvaluation:**

     对 AWS Batch 计算环境进行检查。
   + **ProceedOnlyIfComputeEnvironmentChecksAre好的：**

     根据计算环境检查是否成功进行分支。
   + **UnderlyingInfraEvaluation:**

     根据底层 Auto Scaling 组或 Spot 队列请求执行检查。
   + **ProceedOnlyIfInstancesNotJoiningEcsCluster:**

      根据是否有未加入 Amazon ECS 集群的实例进行分支。
   + **EcsAutomationRunner:**

     为未加入集群的实例运行 Amazon ECS 自动化。
   + **ExecutionResults:**

     根据之前的步骤生成输出。

1. 完成后，将提供评估报告 HTML 文件的 URI：

   **运行手册成功执行后该报告的 S3 控制台链接和 Amazon S3 URI**  
![\[Execution result summary showing errors in compute environment setup and job queue.\]](http://docs.aws.amazon.com/zh_cn/systems-manager-automation-runbooks/latest/userguide/images/awssupport-troubleshoot-aws-batch-job_outputs.png)

 **参考** 

Systems Manager Automation
+ [运行此自动化（控制台）](https://console.aws.amazon.com/systems-manager/automation/execute/AWSSupport-TroubleshootAWSBatchJob)
+ [运行自动化](https://docs.aws.amazon.com//systems-manager/latest/userguide/automation-working-executing.html)
+ [设置自动化](https://docs.aws.amazon.com//systems-manager/latest/userguide/automation-setup.html)
+ [支持自动化工作流登录页面](https://aws.amazon.com/premiumsupport/technology/saw/)