Skip to content

Commit

Permalink
ECS: update_service reflects correct counts (#7714)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafcio19 committed May 24, 2024
1 parent 3308b7b commit 108de5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions moto/ecs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,9 @@ def update_service(self, service_properties: Dict[str, Any]) -> Service:
for prop_name, prop_val in service_properties.items():
if prop_val is not None:
current_service.__setattr__(prop_name, prop_val)
if prop_name == "desired_count":
current_service.__setattr__("running_count", prop_val)
current_service.__setattr__("pending_count", 0)
if task_definition_str:
self.describe_task_definition(task_definition_str)
current_service.task_definition = task_definition_str
Expand Down
4 changes: 4 additions & 0 deletions tests/test_ecs/test_ecs_boto3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,8 @@ def test_update_service():
desiredCount=0,
)
assert response["service"]["desiredCount"] == 0
assert response["service"]["runningCount"] == 0
assert response["service"]["pendingCount"] == 0
assert response["service"]["schedulingStrategy"] == "REPLICA"

# Verify we can pass the ARNs of the cluster and service
Expand All @@ -1243,6 +1245,8 @@ def test_update_service():
desiredCount=1,
)
assert response["service"]["desiredCount"] == 1
assert response["service"]["runningCount"] == 1
assert response["service"]["pendingCount"] == 0


@mock_aws
Expand Down

0 comments on commit 108de5f

Please sign in to comment.