Skip to content

Commit 6ce6694

Browse files
committed
fix so we do not drain too fast
1 parent f3d964d commit 6ce6694

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,15 @@ async def _analyze_current_cluster(
154154
node_used_resources = await auto_scaling_mode.compute_node_used_resources(
155155
app, instance
156156
)
157+
# available resources are total - used -> that means something is still going on on the instance (e.g. processing tasks)
157158
active_nodes.append(
158159
dataclasses.replace(
159160
instance,
160161
available_resources=instance.ec2_instance.resources
161162
- node_used_resources,
162163
)
163164
)
165+
164166
elif utils_docker.is_instance_drained(instance):
165167
all_drained_nodes.append(instance)
166168
elif await auto_scaling_mode.is_instance_retired(app, instance):
@@ -1005,7 +1007,10 @@ async def _find_drainable_nodes(
10051007
drainable_nodes: list[AssociatedInstance] = []
10061008

10071009
for instance in cluster.active_nodes:
1008-
if instance.has_assigned_tasks():
1010+
if instance.has_assigned_tasks() or (
1011+
instance.available_resources < instance.ec2_instance.resources
1012+
):
1013+
# NOTE: we do not (yet) write down processing tasks to the node, so we check also if available resources are less than total resources
10091014
await utils_docker.set_node_found_empty(
10101015
get_docker_client(app), instance.node, empty=False
10111016
)

0 commit comments

Comments
 (0)