getmoto / moto

A library that allows you to easily mock out tests based on AWS infrastructure.

Home Page:http://docs.getmoto.org/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ECS update_service with desiredCount does not affect runningCount

yairsappir opened this issue · comments

Hi,

When calling update_service with desiredCount=x, it doesn't affect the runningCount property of the service.

Steps to reproduce (snippet borrowed from test_ecs_boto3:

client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
client.register_task_definition(
    family="test_ecs_task",
    containerDefinitions=[
        {
            "name": "hello_world",
            "image": "docker/hello-world:latest",
            "cpu": 1024,
            "memory": 400,
            "essential": True,
            "environment": [
                {"name": "AWS_ACCESS_KEY_ID", "value": "SOME_ACCESS_KEY"}
            ],
            "logConfiguration": {"logDriver": "json-file"},
        }
    ],
)
response = client.create_service(
    cluster="test_ecs_cluster",
    serviceName="test_ecs_service",
    taskDefinition="test_ecs_task",
    desiredCount=2,
)
client.update_service(cluster="test_ecs_cluster", service="test_ecs_service", desiredCount=0)
running_count = ecs_client.describe_services(cluster="test_ecs_cluster", services=["test_ecs_service"])['services'][0]['runningCount']
assert 0 == running_count # this fails

Expected behavior would be that when calling update_service and changing the desiredCount, the runningCount should change accordingly.

Note:
The environment variable MOTO_ECS_SERVICE_RUNNING only sets the initial runningCount value, which is ok.

@bblommers I can take a look