无法在 ecs 中启动任务。任务处于 PENDING 状态

无法在 ecs 中启动任务。任务处于 PENDING 状态

我的任务处于“待处理”状态

在此处输入图片描述

这就是我从事件中看到的

在此处输入图片描述

服务事件中没有太多信息。

这是 JSON 格式的任务定义

{
  "requiresAttributes": [
    {
      "value": null,
      "name": "com.amazonaws.ecs.capability.docker-remote-api.1.17",
      "targetId": null,
      "targetType": null
    },
    {
      "value": null,
      "name": "com.amazonaws.ecs.capability.docker-remote-api.1.18",
      "targetId": null,
      "targetType": null
    },
    {
      "value": null,
      "name": "com.amazonaws.ecs.capability.ecr-auth",
      "targetId": null,
      "targetType": null
    },
    {
      "value": null,
      "name": "com.amazonaws.ecs.capability.task-iam-role",
      "targetId": null,
      "targetType": null
    },
    {
      "value": null,
      "name": "com.amazonaws.ecs.capability.logging-driver.awslogs",
      "targetId": null,
      "targetType": null
    },
    {
      "value": null,
      "name": "com.amazonaws.ecs.capability.task-iam-role-network-host",
      "targetId": null,
      "targetType": null
    },
    {
      "value": null,
      "name": "com.amazonaws.ecs.capability.docker-remote-api.1.19",
      "targetId": null,
      "targetType": null
    }
  ],
  "taskDefinitionArn": "arn:aws:ecs:ap-southeast-2:1234567890:task-definition/SQ1-queuetest:1",
  "networkMode": "host",
  "status": "ACTIVE",
  "revision": 1,
  "taskRoleArn": "arn:aws:iam::1234567890:role/play-ecs",
  "containerDefinitions": [
    {
      "volumesFrom": [],
      "memory": 256,
      "extraHosts": null,
      "dnsServers": null,
      "disableNetworking": null,
      "dnsSearchDomains": null,
      "portMappings": [],
      "hostname": null,
      "essential": true,
      "entryPoint": null,
      "mountPoints": [],
      "name": "sq1",
      "ulimits": null,
      "dockerSecurityOptions": null,
      "environment": [
        {
          "name": "ENV",
          "value": "test"
        }
      ],
      "links": null,
      "workingDirectory": "/app/src/",
      "readonlyRootFilesystem": null,
      "image": "1234567890.dkr.ecr.ap-southeast-2.amazonaws.com/simplequeue:latest",
      "command": [
        "python /app/src/main.py"
      ],
      "user": null,
      "dockerLabels": null,
      "logConfiguration": {
        "logDriver": "awslogs",
        "options": {
          "awslogs-group": "simplequeue",
          "awslogs-region": "ap-southeast-2",
          "awslogs-stream-prefix": "sq1"
        }
      },
      "cpu": 512,
      "privileged": null,
      "memoryReservation": null
    }
  ],
  "placementConstraints": [],
  "volumes": [],
  "family": "SQ1-queuetest"
}

我如何才能进一步了解任务启动失败的原因?

答案1

这似乎是由于缺乏政策AmazonEC2ContainerServiceforEC2Role

将此策略分配给角色后,我现在收到不同的错误消息:

在此处输入图片描述

服务 SQ1-test 无法放置任务,因为没有容器实例满足其所有要求。最接近匹配的容器实例 efea641c-6204-4a68-a69f-cb1b07e3529a 遇到错误“AGENT”。有关更多信息,请参阅故障排除部分。

ecsInstanceRole事实证明,上述错误是由于无意中删除了创建集群时创建的角色而导致的。

现在我可以看到状态已变为“待处理” 在此处输入图片描述

相关内容