Skip to content

Commit

Permalink
replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Aug 26, 2024
1 parent b2a68b6 commit 3d8c2ba
Showing 1 changed file with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
SSMCommandExecutionTimeoutError,
)
from fastapi import FastAPI
from models_library.utils.json_serialization import json_dumps, json_loads
from pydantic import NonNegativeInt
from servicelib.logging_utils import log_context
from types_aiobotocore_ec2.literals import InstanceTypeType
Expand All @@ -39,13 +38,16 @@
BUFFER_MACHINE_PULLING_COMMAND_ID_EC2_TAG_KEY,
BUFFER_MACHINE_PULLING_EC2_TAG_KEY,
DOCKER_PULL_COMMAND,
PRE_PULLED_IMAGES_EC2_TAG_KEY,
PREPULL_COMMAND_NAME,
)
from ..core.settings import get_application_settings
from ..models import BufferPool, BufferPoolManager
from ..utils.auto_scaling_core import ec2_buffer_startup_script
from ..utils.buffer_machines_pool_core import get_deactivated_buffer_ec2_tags
from ..utils.buffer_machines_pool_core import (
dump_pre_pulled_images_as_tags,
get_deactivated_buffer_ec2_tags,
load_pre_pulled_images_from_tags,
)
from .auto_scaling_mode_base import BaseAutoscaling
from .ec2 import get_ec2_client
from .ssm import get_ssm_client
Expand Down Expand Up @@ -170,9 +172,7 @@ async def _terminate_instances_with_invalid_pre_pulled_images(

for instance in all_pre_pulled_instances:
if (
pre_pulled_images := json_loads(
instance.tags.get(PRE_PULLED_IMAGES_EC2_TAG_KEY, "[]")
)
pre_pulled_images := load_pre_pulled_images_from_tags(instance.tags)
) and pre_pulled_images != ec2_boot_config.pre_pull_images:
_logger.info(
"%s",
Expand Down Expand Up @@ -314,15 +314,11 @@ async def _handle_pool_image_pulling(
assert app_settings.AUTOSCALING_EC2_INSTANCES # nosec
await ec2_client.set_instances_tags(
tuple(instances_to_stop),
tags={
PRE_PULLED_IMAGES_EC2_TAG_KEY: AWSTagValue(
json_dumps(
app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_ALLOWED_TYPES[
instance_type
].pre_pull_images
)
)
},
tags=dump_pre_pulled_images_as_tags(
app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_ALLOWED_TYPES[
instance_type
].pre_pull_images
),
)
return instances_to_stop, broken_instances_to_terminate

Expand Down

0 comments on commit 3d8c2ba

Please sign in to comment.