gpt4 book ai didi

python - 使用 boto3 ECS 获取 "Creation of service was not idempotent"。为什么?

转载 作者:太空狗 更新时间:2023-10-29 22:09:08 43 4
gpt4 key购买 nike

我正在像这样调用 ecs.create_service:

createServiceResponse = ecs.create_service(
clientToken='abc123',
cluster=options.cluster,
serviceName=options.service,
desiredCount=1,
taskDefinition='relay:' + str(revision),
role='ecsServiceRole',
loadBalancers=[
{
'loadBalancerName': options.elb,
'containerName': 'relay',
'containerPort': 8080
}
]
)

请注意,目前 clientToken 中的值是 abc123,但我已经尝试了各种不同的字符串。该文档说我需要提供它以确保幂等性(http://boto3.readthedocs.org/en/latest/reference/services/ecs.html)但是我不断收到此错误:

Traceback (most recent call last):
File "./deploy.py", line 103, in <module>
'containerPort': 8080
File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 301, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 386, in _make_api_call
raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidParameterException) when calling the CreateService operation: Creation of service was not idempotent.

为什么?

最佳答案

我想通了。

这是因为我在现有服务上调用 create_service。我应该按如下方式调用 update_service:

ecs.update_service(

cluster=options.cluster,
service=options.service,
taskDefinition='relay:' + str(revision),
desiredCount=1)

关于python - 使用 boto3 ECS 获取 "Creation of service was not idempotent"。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33247078/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com