Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECS: update_service reflects correct counts #7714

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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