{
  "id": "aws/ecs-task-stuck-in-pending",
  "signature": "service unable to place tasks: reason: task stuck in PENDING state; cannot pull image or resource unavailable",
  "signature_zh": "服务无法放置任务：原因：任务卡在 PENDING 状态；无法拉取镜像或资源不可用",
  "regex": "service unable to place tasks: reason: task stuck in PENDING state",
  "domain": "aws",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "ECS task fails to transition from PENDING to RUNNING due to insufficient cluster resources (CPU/memory/ports) or image pull failures.",
  "root_cause_type": "generic",
  "root_cause_zh": "ECS 任务无法从 PENDING 转换到 RUNNING，因为集群资源（CPU/内存/端口）不足或镜像拉取失败。",
  "versions": [
    {
      "version": "ECS 1.30.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Amazon Linux 2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Docker 20.10.7",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increase task definition CPU/memory arbitrarily",
      "why_fails": "Incorrect resource sizing wastes capacity; actual cause is cluster saturation or image registry issues.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    },
    {
      "action": "Restart the ECS agent on all instances",
      "why_fails": "Agent restart doesn't free resources or fix image pull problems; only a temporary workaround.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "Delete and recreate the service",
      "why_fails": "Service recreation doesn't change underlying resource constraints or image pull failures.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check ECS cluster capacity: run `aws ecs describe-clusters --cluster your-cluster --include ATTACHMENTS` to see running tasks and remaining resources. Scale out by adding EC2 instances or increase max tasks.",
      "success_rate": 0.75,
      "how": "Check ECS cluster capacity: run `aws ecs describe-clusters --cluster your-cluster --include ATTACHMENTS` to see running tasks and remaining resources. Scale out by adding EC2 instances or increase max tasks.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Verify image pull: test with `docker pull your-image:tag` on an instance. Ensure ECR repository exists and task execution role has ecr:GetDownloadUrlForLayer and ecr:BatchGetImage permissions.",
      "success_rate": 0.85,
      "how": "Verify image pull: test with `docker pull your-image:tag` on an instance. Ensure ECR repository exists and task execution role has ecr:GetDownloadUrlForLayer and ecr:BatchGetImage permissions.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Review task placement constraints: remove or relax constraints like `memberOf` if they're too restrictive. Use `aws ecs describe-tasks --cluster your-cluster --tasks task-id` to get detailed status.",
      "success_rate": 0.7,
      "how": "Review task placement constraints: remove or relax constraints like `memberOf` if they're too restrictive. Use `aws ecs describe-tasks --cluster your-cluster --tasks task-id` to get detailed status.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "检查 ECS 集群容量：运行 `aws ecs describe-clusters --cluster your-cluster --include ATTACHMENTS` 查看运行任务数和剩余资源。通过添加 EC2 实例或增加最大任务数来扩展。",
    "验证镜像拉取：在实例上测试 `docker pull your-image:tag`。确保 ECR 仓库存在且任务执行角色具有 ecr:GetDownloadUrlForLayer 和 ecr:BatchGetImage 权限。",
    "检查任务放置约束：如果约束（如 `memberOf`）过于严格，请移除或放宽。使用 `aws ecs describe-tasks --cluster your-cluster --tasks task-id` 获取详细状态。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-stuck-pending.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}