Skip to content

Commit 5247a91

Browse files
committed
ensure mock does the right thing
1 parent eb2dbb4 commit 5247a91

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/aws-library/src/aws_library/ec2/_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ async def launch_instances(
248248
break
249249
except botocore.exceptions.ClientError as exc:
250250
error_code = exc.response.get("Error", {}).get("Code")
251-
if error_code == "InsufficientInstanceCapacity":
251+
if error_code == "500" and (
252+
"InsufficientInstanceCapacity" in f"{exc}"
253+
):
252254
_logger.warning(
253255
"Insufficient capacity in subnet %s for instance type %s, trying next subnet",
254256
subnet_id,

packages/aws-library/tests/test_ec2_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ async def mock_run_instances(*args, **kwargs) -> Any:
623623
# First call (first subnet) - simulate insufficient capacity
624624
error_response: dict[str, Any] = {
625625
"Error": {
626-
"Code": "InsufficientInstanceCapacity",
626+
"Code": "500",
627627
"Message": "Insufficient capacity.",
628628
},
629629
}
@@ -707,7 +707,7 @@ async def mock_run_instances(*args, **kwargs) -> Any:
707707
# Always simulate insufficient capacity
708708
error_response = {
709709
"Error": {
710-
"Code": "InsufficientInstanceCapacity",
710+
"Code": "500",
711711
"Message": "Insufficient capacity.",
712712
},
713713
}
@@ -784,7 +784,7 @@ async def mock_run_instances(*args, **kwargs):
784784
# Second call: simulate insufficient capacity (subnet is full)
785785
error_response = {
786786
"Error": {
787-
"Code": "InsufficientInstanceCapacity",
787+
"Code": "500",
788788
"Message": "Insufficient capacity.",
789789
},
790790
}

0 commit comments

Comments
 (0)