Skip to content

Commit 725b190

Browse files
committed
refactoring
1 parent 81de3ce commit 725b190

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

services/autoscaling/src/simcore_service_autoscaling/modules/cluster_scaling/_buffer_machines_pool_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
from ...models import BufferPool, BufferPoolManager
4646
from ...utils.buffer_machines import (
4747
dump_pre_pulled_images_as_tags,
48+
ec2_buffer_startup_script,
4849
get_deactivated_buffer_ec2_tags,
4950
load_pre_pulled_images_from_tags,
5051
)
51-
from ...utils.cluster_scaling import ec2_buffer_startup_script
5252
from ..ec2 import get_ec2_client
5353
from ..instrumentation import get_instrumentation, has_instrumentation
5454
from ..ssm import get_ssm_client

services/autoscaling/src/simcore_service_autoscaling/utils/buffer_machines.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Final
44

55
from aws_library.ec2 import AWS_TAG_VALUE_MAX_LENGTH, AWSTagKey, AWSTagValue, EC2Tags
6+
from aws_library.ec2._models import EC2InstanceBootSpecific
67
from common_library.json_serialization import json_dumps
78
from models_library.docker import DockerGenericTag
89
from pydantic import TypeAdapter
@@ -14,6 +15,8 @@
1415
PRE_PULLED_IMAGES_EC2_TAG_KEY,
1516
PRE_PULLED_IMAGES_RE,
1617
)
18+
from ..core.settings import ApplicationSettings
19+
from .utils import utils_docker
1720

1821
_NAME_EC2_TAG_KEY: Final[AWSTagKey] = TypeAdapter(AWSTagKey).validate_python("Name")
1922

@@ -85,3 +88,22 @@ def load_pre_pulled_images_from_tags(tags: EC2Tags) -> list[DockerGenericTag]:
8588
if assembled_json:
8689
return TypeAdapter(list[DockerGenericTag]).validate_json(assembled_json)
8790
return []
91+
92+
93+
def ec2_buffer_startup_script(
94+
ec2_boot_specific: EC2InstanceBootSpecific, app_settings: ApplicationSettings
95+
) -> str:
96+
startup_commands = ec2_boot_specific.custom_boot_scripts.copy()
97+
if ec2_boot_specific.pre_pull_images:
98+
assert app_settings.AUTOSCALING_REGISTRY # nosec
99+
startup_commands.extend(
100+
(
101+
utils_docker.get_docker_login_on_start_bash_command(
102+
app_settings.AUTOSCALING_REGISTRY
103+
),
104+
utils_docker.write_compose_file_command(
105+
ec2_boot_specific.pre_pull_images
106+
),
107+
)
108+
)
109+
return " && ".join(startup_commands)

services/autoscaling/src/simcore_service_autoscaling/utils/cluster_scaling.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,6 @@ async def ec2_startup_script(
8585
return " && ".join(startup_commands)
8686

8787

88-
def ec2_buffer_startup_script(
89-
ec2_boot_specific: EC2InstanceBootSpecific, app_settings: ApplicationSettings
90-
) -> str:
91-
startup_commands = ec2_boot_specific.custom_boot_scripts.copy()
92-
if ec2_boot_specific.pre_pull_images:
93-
assert app_settings.AUTOSCALING_REGISTRY # nosec
94-
startup_commands.extend(
95-
(
96-
utils_docker.get_docker_login_on_start_bash_command(
97-
app_settings.AUTOSCALING_REGISTRY
98-
),
99-
utils_docker.write_compose_file_command(
100-
ec2_boot_specific.pre_pull_images
101-
),
102-
)
103-
)
104-
return " && ".join(startup_commands)
105-
106-
10788
def _instance_type_by_type_name(
10889
ec2_type: EC2InstanceType, *, type_name: InstanceTypeType | None
10990
) -> bool:

0 commit comments

Comments
 (0)