From 8a869c4ba3778c6f865f110ab97832a2bbdb6e92 Mon Sep 17 00:00:00 2001 From: Kyujin Cho Date: Fri, 14 Feb 2025 19:53:03 +0900 Subject: [PATCH] fix(BA-660): Model service not destroyed when auto scaling rule is set --- changes/.fix.md | 1 + src/ai/backend/manager/models/endpoint.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changes/.fix.md diff --git a/changes/.fix.md b/changes/.fix.md new file mode 100644 index 0000000000..02aff7e11d --- /dev/null +++ b/changes/.fix.md @@ -0,0 +1 @@ +Fix model service not removed when auto scaling rules are set diff --git a/src/ai/backend/manager/models/endpoint.py b/src/ai/backend/manager/models/endpoint.py index 1812605b6b..0e3a2ad0d0 100644 --- a/src/ai/backend/manager/models/endpoint.py +++ b/src/ai/backend/manager/models/endpoint.py @@ -640,10 +640,19 @@ class EndpointAutoScalingRuleRow(Base): endpoint_row = relationship("EndpointRow", back_populates="endpoint_auto_scaling_rules") @classmethod - async def list(cls, session: AsyncSession, load_endpoint=False) -> Sequence[Self]: + async def list( + cls, + session: AsyncSession, + load_endpoint=False, + endpoint_status_filter: Container[EndpointLifecycle] = frozenset([ + EndpointLifecycle.CREATED + ]), + ) -> Sequence[Self]: query = sa.select(EndpointAutoScalingRuleRow) if load_endpoint: query = query.options(selectinload(EndpointAutoScalingRuleRow.endpoint_row)) + if endpoint_status_filter: + query = query.filter(EndpointRow.lifecycle_stage.in_(endpoint_status_filter)) result = await session.execute(query) return result.scalars().all()