12

我正在打这样的电话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.

为什么 ?

4

1 回答 1

26

我想到了。

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

ecs.update_service(

cluster=options.cluster,
service=options.service,
taskDefinition='relay:' + str(revision),    
desiredCount=1) 
于 2015-10-20T22:48:52.197 回答