Skip to content

Commit 5358fa1

Browse files
committed
changed ENV to plural
1 parent 258e0c5 commit 5358fa1

File tree

13 files changed

+63
-59
lines changed

13 files changed

+63
-59
lines changed

services/autoscaling/src/simcore_service_autoscaling/core/settings.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,14 @@ class EC2InstancesSettings(BaseCustomSettings):
112112
" this is required to start a new EC2 instance",
113113
),
114114
]
115-
EC2_INSTANCES_SUBNET_ID: Annotated[
116-
str,
115+
EC2_INSTANCES_SUBNET_IDS: Annotated[
116+
list[str],
117117
Field(
118118
min_length=1,
119119
description="A subnet is a range of IP addresses in your VPC "
120120
" (https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html), "
121-
"this is required to start a new EC2 instance",
121+
"this is required to start a new EC2 instance. The subnets are used in the given order "
122+
"until the capacity is used up.",
122123
),
123124
]
124125
EC2_INSTANCES_TIME_BEFORE_DRAINING: Annotated[

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ async def _launch_instances(
816816
].ami_id,
817817
key_name=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_KEY_NAME,
818818
security_group_ids=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_SECURITY_GROUP_IDS,
819-
subnet_ids=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_SUBNET_ID,
819+
subnet_ids=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_SUBNET_IDS,
820820
iam_instance_profile=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_ATTACHED_IAM_PROFILE,
821821
),
822822
min_number_of_instances=1, # NOTE: we want at least 1 if possible

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ async def _add_remove_buffer_instances(
311311
ami_id=ec2_boot_specific.ami_id,
312312
key_name=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_KEY_NAME,
313313
security_group_ids=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_SECURITY_GROUP_IDS,
314-
subnet_ids=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_SUBNET_ID,
314+
subnet_ids=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_SUBNET_IDS,
315315
iam_instance_profile=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_ATTACHED_IAM_PROFILE,
316316
),
317317
min_number_of_instances=1, # NOTE: we want at least 1

services/autoscaling/tests/manual/.env-devel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ EC2_INSTANCES_ATTACHED_IAM_PROFILE=XXXXXXXXX
2121
EC2_INSTANCES_KEY_NAME=XXXXXXXXXX
2222
EC2_INSTANCES_NAME_PREFIX=testing-osparc-computational-cluster
2323
EC2_INSTANCES_SECURITY_GROUP_IDS=["XXXXXXXXXX"]
24-
EC2_INSTANCES_SUBNET_ID=XXXXXXXXXX
24+
EC2_INSTANCES_SUBNET_IDS=["XXXXXXXXXX"]
2525
EC2_INSTANCES_CUSTOM_TAGS={"special": "testing"}
2626
EC2_INSTANCES_TIME_BEFORE_DRAINING=00:00:20
2727
EC2_INSTANCES_TIME_BEFORE_TERMINATION=00:01:00

services/autoscaling/tests/unit/conftest.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,11 @@ def app_environment(
261261
"SSM_ACCESS_KEY_ID": faker.pystr(),
262262
"SSM_SECRET_ACCESS_KEY": faker.pystr(),
263263
"EC2_INSTANCES_KEY_NAME": faker.pystr(),
264-
"EC2_INSTANCES_SECURITY_GROUP_IDS": json.dumps(
264+
"EC2_INSTANCES_SECURITY_GROUP_IDS": json_dumps(
265265
faker.pylist(allowed_types=(str,))
266266
),
267-
"EC2_INSTANCES_SUBNET_ID": faker.pystr(),
268-
"EC2_INSTANCES_ALLOWED_TYPES": json.dumps(
267+
"EC2_INSTANCES_SUBNET_IDS": json_dumps(faker.pylist(allowed_types=(str,))),
268+
"EC2_INSTANCES_ALLOWED_TYPES": json_dumps(
269269
{
270270
ec2_type_name: random.choice( # noqa: S311
271271
EC2InstanceBootSpecific.model_config["json_schema_extra"][
@@ -275,7 +275,7 @@ def app_environment(
275275
for ec2_type_name in aws_allowed_ec2_instance_type_names
276276
}
277277
),
278-
"EC2_INSTANCES_CUSTOM_TAGS": json.dumps(ec2_instance_custom_tags),
278+
"EC2_INSTANCES_CUSTOM_TAGS": json_dumps(ec2_instance_custom_tags),
279279
"EC2_INSTANCES_ATTACHED_IAM_PROFILE": faker.pystr(),
280280
},
281281
)
@@ -301,9 +301,9 @@ def mocked_ec2_instances_envs(
301301
monkeypatch,
302302
{
303303
"EC2_INSTANCES_KEY_NAME": "osparc-pytest",
304-
"EC2_INSTANCES_SECURITY_GROUP_IDS": json.dumps([aws_security_group_id]),
305-
"EC2_INSTANCES_SUBNET_ID": aws_subnet_id,
306-
"EC2_INSTANCES_ALLOWED_TYPES": json.dumps(
304+
"EC2_INSTANCES_SECURITY_GROUP_IDS": json_dumps([aws_security_group_id]),
305+
"EC2_INSTANCES_SUBNET_IDS": json_dumps([aws_subnet_id]),
306+
"EC2_INSTANCES_ALLOWED_TYPES": json_dumps(
307307
{
308308
ec2_type_name: cast(
309309
dict,
@@ -371,11 +371,11 @@ def enabled_dynamic_mode(
371371
monkeypatch,
372372
{
373373
"AUTOSCALING_NODES_MONITORING": "{}",
374-
"NODES_MONITORING_NODE_LABELS": json.dumps(["pytest.fake-node-label"]),
375-
"NODES_MONITORING_SERVICE_LABELS": json.dumps(
374+
"NODES_MONITORING_NODE_LABELS": json_dumps(["pytest.fake-node-label"]),
375+
"NODES_MONITORING_SERVICE_LABELS": json_dumps(
376376
["pytest.fake-service-label"]
377377
),
378-
"NODES_MONITORING_NEW_NODES_LABELS": json.dumps(
378+
"NODES_MONITORING_NEW_NODES_LABELS": json_dumps(
379379
["pytest.fake-new-node-label"]
380380
),
381381
},
@@ -756,9 +756,9 @@ async def _() -> None:
756756
assert tasks, f"no tasks available for {found_service['Spec']['Name']}"
757757
assert len(tasks) == 1
758758
service_task = tasks[0]
759-
assert service_task["Status"]["State"] in expected_states, (
760-
f"service {found_service['Spec']['Name']}'s task is {service_task['Status']['State']}"
761-
)
759+
assert (
760+
service_task["Status"]["State"] in expected_states
761+
), f"service {found_service['Spec']['Name']}'s task is {service_task['Status']['State']}"
762762
ctx.logger.info(
763763
"%s",
764764
f"service {found_service['Spec']['Name']} is now {service_task['Status']['State']} {'.' * number_of_success['count']}",
@@ -792,7 +792,7 @@ def aws_allowed_ec2_instance_type_names_env(
792792
aws_allowed_ec2_instance_type_names: list[InstanceTypeType],
793793
) -> EnvVarsDict:
794794
changed_envs: dict[str, str | bool] = {
795-
"EC2_INSTANCES_ALLOWED_TYPES": json.dumps(aws_allowed_ec2_instance_type_names),
795+
"EC2_INSTANCES_ALLOWED_TYPES": json_dumps(aws_allowed_ec2_instance_type_names),
796796
}
797797
return app_environment | setenvs_from_dict(monkeypatch, changed_envs)
798798

@@ -985,9 +985,7 @@ def _creator(
985985
assert (
986986
datetime.timedelta(seconds=10)
987987
< app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_TIME_BEFORE_TERMINATION
988-
), (
989-
"this tests relies on the fact that the time before termination is above 10 seconds"
990-
)
988+
), "this tests relies on the fact that the time before termination is above 10 seconds"
991989
assert app_settings.AUTOSCALING_EC2_INSTANCES
992990
seconds_delta = (
993991
-datetime.timedelta(seconds=10)
@@ -1128,12 +1126,12 @@ def ec2_instances_allowed_types_with_only_1_buffered(
11281126
allowed_ec2_types.items(),
11291127
)
11301128
)
1131-
assert allowed_ec2_types_with_buffer_defined, (
1132-
"one type with buffer is needed for the tests!"
1133-
)
1134-
assert len(allowed_ec2_types_with_buffer_defined) == 1, (
1135-
"more than one type with buffer is disallowed in this test!"
1136-
)
1129+
assert (
1130+
allowed_ec2_types_with_buffer_defined
1131+
), "one type with buffer is needed for the tests!"
1132+
assert (
1133+
len(allowed_ec2_types_with_buffer_defined) == 1
1134+
), "more than one type with buffer is disallowed in this test!"
11371135
return {
11381136
TypeAdapter(InstanceTypeType).validate_python(k): v
11391137
for k, v in allowed_ec2_types_with_buffer_defined.items()
@@ -1157,9 +1155,9 @@ def _by_buffer_count(
11571155
filter(_by_buffer_count, allowed_ec2_types.items())
11581156
)
11591157
assert allowed_ec2_types_with_buffer_defined, "you need one type with buffer"
1160-
assert len(allowed_ec2_types_with_buffer_defined) == 1, (
1161-
"more than one type with buffer is disallowed in this test!"
1162-
)
1158+
assert (
1159+
len(allowed_ec2_types_with_buffer_defined) == 1
1160+
), "more than one type with buffer is disallowed in this test!"
11631161
return next(iter(allowed_ec2_types_with_buffer_defined.values())).buffer_count
11641162

11651163

@@ -1209,7 +1207,9 @@ async def _do(
12091207
InstanceType=instance_type,
12101208
KeyName=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_KEY_NAME,
12111209
SecurityGroupIds=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_SECURITY_GROUP_IDS,
1212-
SubnetId=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_SUBNET_ID,
1210+
SubnetId=app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_SUBNET_IDS[
1211+
0
1212+
],
12131213
IamInstanceProfile={
12141214
"Arn": app_settings.AUTOSCALING_EC2_INSTANCES.EC2_INSTANCES_ATTACHED_IAM_PROFILE
12151215
},

services/clusters-keeper/.env-devel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ EC2_CLUSTERS_KEEPER_ACCESS_KEY_ID=XXXXXXXXXX
66
PRIMARY_EC2_INSTANCES_ALLOWED_TYPES='{"t2.medium":"ami_id": "XXXXXXXXXX", "custom_boot_scripts": ["whoami"]}}'
77
PRIMARY_EC2_INSTANCES_KEY_NAME=XXXXXXXXXX
88
PRIMARY_EC2_INSTANCES_SECURITY_GROUP_IDS=XXXXXXXXXX
9-
PRIMARY_EC2_INSTANCES_SUBNET_ID=XXXXXXXXXX
9+
PRIMARY_EC2_INSTANCES_SUBNET_IDS='["XXXXXXXXXX"]'
1010
EC2_CLUSTERS_KEEPER_SECRET_ACCESS_KEY=XXXXXXXXXX
1111
CLUSTERS_KEEPER_EC2_INSTANCES_PREFIX="testing"
1212
LOG_FORMAT_LOCAL_DEV_ENABLED=True

services/clusters-keeper/src/simcore_service_clusters_keeper/core/settings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ class WorkersEC2InstancesSettings(BaseCustomSettings):
118118
" this is required to start a new EC2 instance",
119119
),
120120
]
121-
WORKERS_EC2_INSTANCES_SUBNET_ID: Annotated[
122-
str,
121+
WORKERS_EC2_INSTANCES_SUBNET_IDS: Annotated[
122+
list[str],
123123
Field(
124124
min_length=1,
125125
description="A subnet is a range of IP addresses in your VPC "
@@ -186,8 +186,8 @@ class PrimaryEC2InstancesSettings(BaseCustomSettings):
186186
" this is required to start a new EC2 instance",
187187
),
188188
]
189-
PRIMARY_EC2_INSTANCES_SUBNET_ID: Annotated[
190-
str,
189+
PRIMARY_EC2_INSTANCES_SUBNET_IDS: Annotated[
190+
list[str],
191191
Field(
192192
min_length=1,
193193
description="A subnet is a range of IP addresses in your VPC "

services/clusters-keeper/src/simcore_service_clusters_keeper/data/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ services:
111111
EC2_INSTANCES_MAX_INSTANCES: ${WORKERS_EC2_INSTANCES_MAX_INSTANCES}
112112
EC2_INSTANCES_NAME_PREFIX: ${EC2_INSTANCES_NAME_PREFIX}
113113
EC2_INSTANCES_SECURITY_GROUP_IDS: ${WORKERS_EC2_INSTANCES_SECURITY_GROUP_IDS}
114-
EC2_INSTANCES_SUBNET_ID: ${WORKERS_EC2_INSTANCES_SUBNET_ID}
114+
EC2_INSTANCES_SUBNET_IDS: ${WORKERS_EC2_INSTANCES_SUBNET_IDS}
115115
EC2_INSTANCES_TIME_BEFORE_DRAINING: ${WORKERS_EC2_INSTANCES_TIME_BEFORE_DRAINING}
116116
EC2_INSTANCES_TIME_BEFORE_TERMINATION: ${WORKERS_EC2_INSTANCES_TIME_BEFORE_TERMINATION}
117117
LOG_FORMAT_LOCAL_DEV_ENABLED: 1

services/clusters-keeper/src/simcore_service_clusters_keeper/modules/clusters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ async def create_cluster(
7777
ami_id=ec2_instance_boot_specs.ami_id,
7878
key_name=app_settings.CLUSTERS_KEEPER_PRIMARY_EC2_INSTANCES.PRIMARY_EC2_INSTANCES_KEY_NAME,
7979
security_group_ids=app_settings.CLUSTERS_KEEPER_PRIMARY_EC2_INSTANCES.PRIMARY_EC2_INSTANCES_SECURITY_GROUP_IDS,
80-
subnet_ids=app_settings.CLUSTERS_KEEPER_PRIMARY_EC2_INSTANCES.PRIMARY_EC2_INSTANCES_SUBNET_ID,
80+
subnet_ids=app_settings.CLUSTERS_KEEPER_PRIMARY_EC2_INSTANCES.PRIMARY_EC2_INSTANCES_SUBNET_IDS,
8181
iam_instance_profile=app_settings.CLUSTERS_KEEPER_PRIMARY_EC2_INSTANCES.PRIMARY_EC2_INSTANCES_ATTACHED_IAM_PROFILE,
8282
)
8383
new_ec2_instance_data: list[EC2InstanceData] = await ec2_client.launch_instances(

services/clusters-keeper/src/simcore_service_clusters_keeper/utils/clusters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _convert_to_env_dict(entries: dict[str, Any]) -> str:
102102
f"WORKERS_EC2_INSTANCES_KEY_NAME={app_settings.CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES.WORKERS_EC2_INSTANCES_KEY_NAME}",
103103
f"WORKERS_EC2_INSTANCES_MAX_INSTANCES={app_settings.CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES.WORKERS_EC2_INSTANCES_MAX_INSTANCES}",
104104
f"WORKERS_EC2_INSTANCES_SECURITY_GROUP_IDS={_convert_to_env_list(app_settings.CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES.WORKERS_EC2_INSTANCES_SECURITY_GROUP_IDS)}",
105-
f"WORKERS_EC2_INSTANCES_SUBNET_ID={app_settings.CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES.WORKERS_EC2_INSTANCES_SUBNET_ID}",
105+
f"WORKERS_EC2_INSTANCES_SUBNET_IDS={app_settings.CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES.WORKERS_EC2_INSTANCES_SUBNET_IDS}",
106106
f"WORKERS_EC2_INSTANCES_TIME_BEFORE_DRAINING={app_settings.CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES.WORKERS_EC2_INSTANCES_TIME_BEFORE_DRAINING}",
107107
f"WORKERS_EC2_INSTANCES_TIME_BEFORE_TERMINATION={app_settings.CLUSTERS_KEEPER_WORKERS_EC2_INSTANCES.WORKERS_EC2_INSTANCES_TIME_BEFORE_TERMINATION}",
108108
f"AUTOSCALING_RABBITMQ={_convert_to_env_dict(model_dump_with_secrets(app_settings.CLUSTERS_KEEPER_PRIMARY_EC2_INSTANCES.PRIMARY_EC2_INSTANCES_RABBIT, show_secrets=True)) if app_settings.CLUSTERS_KEEPER_PRIMARY_EC2_INSTANCES.PRIMARY_EC2_INSTANCES_RABBIT else 'null'}",

0 commit comments

Comments
 (0)