GitLab CI 停留在 "Waiting Fargate task to be ready" - 但 Fargate 任务实际上是 运行,但从未完成

GitLab CI stuck at "Waiting Fargate task to be ready" - but Fargate task is in fact running, but never completes

按照 the documentation 中所述设置 GitLab CI 和 AWS Fargate 资源后,我们会遇到运行器可以触发进入 运行 状态的 Fargate 任务的情况,但是高手似乎从来没有意识到这一点。

Running with gitlab-runner 14.7.0 (98daeee0)
  on gitlab-fargate-master DyE5BsVA
Preparing the "custom" executor
INFO[2022-01-27T13:54:49Z] Starting fargate                              PID=1447 version="0.2.0 (933d940)"
INFO[2022-01-27T13:54:49Z] Executing the command                         PID=1447 command=config_exec
Using Custom executor with driver fargate 0.2.0 (933d940)...
INFO[2022-01-27T13:54:49Z] Starting fargate                              PID=1452 version="0.2.0 (933d940)"
INFO[2022-01-27T13:54:49Z] Executing the command                         PID=1452 command=prepare_exec
INFO[2022-01-27T13:54:56Z] Starting new Fargate task                     PID=1452 command=prepare_exec
INFO[2022-01-27T13:54:58Z] Persisting data that will be used by other commands  PID=1452 command=prepare_exec taskARN="arn:aws:ecs:us-east-1:558517226390:task/gitlab-ci-cluster/ee488fa1d7d7475fab9be01d5bad180e"
INFO[2022-01-27T13:54:58Z] Waiting Fargate task to be ready              PID=1452 command=prepare_exec taskARN="arn:aws:ecs:us-east-1:558517226390:task/gitlab-ci-cluster/ee488fa1d7d7475fab9be01d5bad180e"

在 AWS 中,任务已在 Cloudwatch 中创建其日志流,但该日志中没有事件。目前尚不清楚实际发生了什么。

可以做些什么来找出答案?

我们已恢复使用来自 GitLab 文档 registry.gitlab.com/tmaczukin-test-projects/fargate-driver-debian:latest 的普通 Docker 容器,但发生的情况完全相同。

不确定您是否已解决问题,但我注意到了这个问题,因为我昨天遇到了完全相同的问题。对我来说,这是因为我的 gitlab 管理器任务使用的 IAM 角色仅限于启动和停止任务,但它显然缺少检查任务是否处于 运行 状态的天气的权限。所以我修复了我的 ecs 执行角色,然后它开始为我工作。

已解决 - 问题是缺少 AWS 权限 ECS:DescribeTasks,出于某种原因,这并没有在 Runner 中导致错误消息。

(我错误地添加了 AmazonEC2_FullAccess,而不是 the docs 中描述的 AmazonECS_FullAccess)

在 AWS 中有 运行 基于 CloudTrail 事件的“生成策略”(很棒的新功能!),我现在可以确认实际使用的权限是:

EC2:描述网络接口。 ECS:StopTask、DescribeTasks、RunTask

注意文档中缺少的 EC2 权限。