|
14 | 14 | EC2Tags,
|
15 | 15 | Resources,
|
16 | 16 | )
|
| 17 | +from aws_library.ec2._errors import ( |
| 18 | + EC2InstanceNotFoundError, |
| 19 | + EC2InstanceTypeInvalidError, |
| 20 | + EC2TooManyInstancesError, |
| 21 | +) |
17 | 22 | from fastapi import FastAPI
|
18 | 23 | from models_library.generated_models.docker_rest_api import Node, NodeState
|
19 | 24 | from servicelib.logging_utils import log_catch, log_context
|
20 | 25 | from servicelib.utils_formatting import timedelta_as_minute_second
|
21 | 26 | from types_aiobotocore_ec2.literals import InstanceTypeType
|
22 | 27 |
|
23 |
| -from ..core.errors import ( |
24 |
| - Ec2InstanceInvalidError, |
25 |
| - Ec2InstanceNotFoundError, |
26 |
| - Ec2InvalidDnsNameError, |
27 |
| - Ec2TooManyInstancesError, |
28 |
| -) |
| 28 | +from ..core.errors import Ec2InvalidDnsNameError |
29 | 29 | from ..core.settings import ApplicationSettings, get_application_settings
|
30 | 30 | from ..models import (
|
31 | 31 | AssignedTasksToInstanceType,
|
@@ -497,13 +497,13 @@ async def _find_needed_instances(
|
497 | 497 | - task_required_resources,
|
498 | 498 | )
|
499 | 499 | )
|
500 |
| - except Ec2InstanceNotFoundError: |
| 500 | + except EC2InstanceNotFoundError: |
501 | 501 | _logger.exception(
|
502 | 502 | "Task %s needs more resources than any EC2 instance "
|
503 | 503 | "can provide with the current configuration. Please check!",
|
504 | 504 | f"{task}",
|
505 | 505 | )
|
506 |
| - except Ec2InstanceInvalidError: |
| 506 | + except EC2InstanceTypeInvalidError: |
507 | 507 | _logger.exception("Unexpected error:")
|
508 | 508 |
|
509 | 509 | _logger.info(
|
@@ -568,7 +568,7 @@ async def _cap_needed_instances(
|
568 | 568 | >= app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_MAX_INSTANCES
|
569 | 569 | ):
|
570 | 570 | # ok that is already too much
|
571 |
| - raise Ec2TooManyInstancesError( |
| 571 | + raise EC2TooManyInstancesError( |
572 | 572 | num_instances=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_MAX_INSTANCES
|
573 | 573 | )
|
574 | 574 |
|
|
0 commit comments