Amazon web services 内存和cpu的AWS ECS运行任务覆盖不工作
我试图在使用命令时覆盖容器上的CPU和内存限制。我正在使用Python SDK,boto3 容器的默认CPU限制为0(无限制),软内存限制为1024。那很好 当我试图将Amazon web services 内存和cpu的AWS ECS运行任务覆盖不工作,amazon-web-services,docker,boto3,aws-ecs,Amazon Web Services,Docker,Boto3,Aws Ecs,我试图在使用命令时覆盖容器上的CPU和内存限制。我正在使用Python SDK,boto3 容器的默认CPU限制为0(无限制),软内存限制为1024。那很好 当我试图将containerOverrides列表传递给RunTask命令时,我没有收到错误,任务大部分按预期运行。我还重写了容器运行的命令,这是有效的-我可以看到任务正在运行,命令已经被重写,日志反映了这一点 但是,CPU和内存限制没有被覆盖。我正在查看AWS控制台,看到CPU和内存列为0和1024,但命令显示被覆盖。我还可以通过检查容器
containerOverrides
列表传递给RunTask命令时,我没有收到错误,任务大部分按预期运行。我还重写了容器运行的命令,这是有效的-我可以看到任务正在运行,命令已经被重写,日志反映了这一点
但是,CPU和内存限制没有被覆盖。我正在查看AWS控制台,看到CPU和内存列为0和1024,但命令显示被覆盖。我还可以通过检查容器实例来做一些计算,以确认内存不是期望的2048,但必须是1024
下面是一些简化的代码:
import boto3
client = boto3.client('ecs')
overrides = {
"containerOverrides": [
{
"name": "runcommand",
"command": command_wrapper,
"cpu": 512,
"memory": 2048,
"memoryReservation": 2048
}
]
}
response = client.run_task(
cluster='mycluster',
taskDefinition='runcommand-qa',
overrides=overrides,
group='stackoverflow:run-command'
)
以及响应的任务
部分:
'tasks': [{
'taskArn': 'arn:aws:ecs:us-east-1:12345667890:task/72f1a8ae-4f51-4717-acc6-fce3199a9e92',
'group': 'stackoverflow:run-command',
'attachments': [],
'overrides': {
'containerOverrides': [{
'memoryReservation': 2048,
'memory': 2048,
'command': ['sh', '-c', '. /app/bin/activate && ./manage.py help'],
'name': 'runcommand',
'cpu': 512
}]
},
'launchType': 'EC2',
'lastStatus': 'PENDING',
'containerInstanceArn': 'arn:aws:ecs:us-east-1:12345667890:container-instance/f0dd320e-b1de-413d-8e1c-c64b0799e473',
'createdAt': datetime.datetime(2018, 5, 25, 9, 4, 3, 46000, tzinfo = tzlocal()),
'version': 1,
'clusterArn': 'arn:aws:ecs:us-east-1:12345667890:cluster/runcommand-qa',
'memory': '2048',
'desiredStatus': 'RUNNING',
'taskDefinitionArn': 'arn:aws:ecs:us-east-1:12345667890:task-definition/runcommand-qa:127',
'cpu': '512',
'containers': [{
'containerArn': 'arn:aws:ecs:us-east-1:12345667890:container/80949a81-747f-4729-a9d4-922007448729',
'taskArn': 'arn:aws:ecs:us-east-1:12345667890:task/72f1a8ae-4f51-4717-acc6-fce3199a9e92',
'lastStatus': 'PENDING',
'name': 'runcommand',
'networkInterfaces': []
}]
}]
我错过了什么