Skip to content

Commit 83bf3b0

Browse files
committed
add generic instances based on the provider
1 parent de93669 commit 83bf3b0

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ async def _analyze_current_cluster(
112112
state_names=["stopped"],
113113
)
114114

115+
for instance in itertools.chain(existing_ec2_instances, warm_buffer_ec2_instances):
116+
auto_scaling_mode.add_instance_generic_resources(app, instance)
117+
115118
attached_ec2s, pending_ec2s = associate_ec2_instances_with_nodes(
116119
docker_nodes, existing_ec2_instances
117120
)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,12 @@ async def is_instance_retired(
182182
async def try_retire_nodes(self, app: FastAPI) -> None:
183183
assert self # nosec
184184
await dask.try_retire_nodes(_scheduler_url(app), _scheduler_auth(app))
185+
186+
def add_instance_generic_resources(
187+
self, app: FastAPI, instance: EC2InstanceData
188+
) -> None:
189+
assert self # nosec
190+
assert app # nosec
191+
app_settings = get_application_settings(app)
192+
assert app_settings.AUTOSCALING_DASK # nosec
193+
dask.add_instance_generic_resources(app_settings.AUTOSCALING_DASK, instance)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ async def is_instance_retired(
4747
) -> bool: ...
4848

4949
async def try_retire_nodes(self, app: FastAPI) -> None: ...
50+
51+
def add_instance_generic_resources(
52+
self, app: FastAPI, instance: EC2InstanceData
53+
) -> None: ...

services/autoscaling/src/simcore_service_autoscaling/modules/dask.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from dask_task_models_library.resource_constraints import (
1313
DASK_WORKER_THREAD_RESOURCE_NAME,
1414
DaskTaskResources,
15+
create_ec2_resource_constraint_key,
1516
)
1617
from distributed.core import Status
1718
from models_library.clusters import ClusterAuthentication, TLSAuthentication
@@ -339,6 +340,9 @@ async def try_retire_nodes(
339340
)
340341

341342

343+
_LARGE_RESOURCE: Final[int] = 99999
344+
345+
342346
def add_instance_generic_resources(
343347
settings: DaskMonitoringSettings, instance: EC2InstanceData
344348
) -> None:
@@ -351,3 +355,7 @@ def add_instance_generic_resources(
351355
instance.resources.generic_resources[DASK_WORKER_THREAD_RESOURCE_NAME] = (
352356
instance_threads
353357
)
358+
359+
instance.resources.generic_resources[
360+
create_ec2_resource_constraint_key(instance.type)
361+
] = _LARGE_RESOURCE

services/autoscaling/tests/unit/test_modules_cluster_scaling_computational.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ async def test_cluster_scaling_up_and_down( # noqa: PLR0915
638638
)
639639
mock_docker_tag_node.reset_mock()
640640
mock_docker_set_node_availability.assert_not_called()
641-
mock_rabbitmq_post_message.assert_called_once()
641+
assert mock_rabbitmq_post_message.call_count == 3
642642
mock_rabbitmq_post_message.reset_mock()
643643

644644
# now we have 1 monitored node that needs to be mocked

0 commit comments

Comments
 (0)