簡體   English   中英

為什么我不能在 AWS ECS 中運行多個任務?

[英]Why can't I run multiple tasks in AWS ECS?

我正在開發一個文件處理系統,可以將文件上傳到 S3,然后在容器中進行處理。 我一直在使用觸發 ECS 從 lambda 運行任務並傳遞一些環境變量。

S3 -> Lambda -> ECS

我遇到了一個問題,我似乎無法一次運行超過 1 個任務。 如果一個任務已經在運行,那么任何后續運行的任務都會卡在“PROVISIONING”中並最終完全消失。

這是我運行 ECS 任務的 lambda 函數:

const params: RunTaskRequest = {
    launchType: "FARGATE",
    cluster: "arn:aws:ecs:us-east-1:XXXXXXX:cluster/FileProcessingCluster",
    taskDefinition: "XXX",
    networkConfiguration: {
        awsvpcConfiguration: {
            subnets: [
                "subnet-XXX",
                "subnet-XXX"
            ],
            securityGroups: [
                "..."
            ],
            assignPublicIp: "DISABLED"
        }
    },
    overrides: {
        containerOverrides: [
            {
                name: "FileProcessingContainer",
                environment: [
                    ...
                ]
            },
        ]
    },
};

try {
    await ecs.runTask(params).promise(); 
}catch (e) {
    console.error(e, e.stack)       
}

我正在使用 AWS-CDK 創建 ECS 基礎設施:

    const cluster = new ecs.Cluster(this, 'FileProcessingCluster', {
        clusterName: "FileProcessingCluster"
    });

    const taskDefinition = new ecs.FargateTaskDefinition(this, "FileProcessingTask", {
        memoryLimitMiB: 8192,
        cpu: 4096,
    });

    taskDefinition.addContainer("FileProcessingContainer", {
        image: ecs.ContainerImage.fromAsset("../local-image"),
        logging: new ecs.AwsLogDriver({
            streamPrefix: `${id}`
        }),
        memoryLimitMiB: 8192,
        cpu: 4096,
    });

有什么我在這里想念的嗎? 也許與並發任務相關的設置?

事實證明,我在任務定義中錯誤配置了子網,這阻止了從 ECR 中提取圖像。

您可以在此處閱讀更多相關信息: ECS 任務未啟動 - STOPPED(CannotPullContainerError:“在等待連接時取消了來自守護進程請求的錯誤響應”

還有: https : //aws.amazon.com/premiumsupport/knowledge-center/ecs-pull-container-error/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM