|
11 | 11 | from ai.backend.manager.data.deployment.types import ( |
12 | 12 | DeploymentHandlerCategory, |
13 | 13 | DeploymentHistoryData, |
| 14 | + RouteHandlerCategory, |
14 | 15 | RouteHistoryData, |
15 | 16 | ) |
16 | 17 | from ai.backend.manager.data.kernel.types import ( |
@@ -252,19 +253,22 @@ class RouteHistoryRow(Base): # type: ignore[misc] |
252 | 253 | "deployment_id", GUID, nullable=False, index=True |
253 | 254 | ) |
254 | 255 |
|
255 | | - category: Mapped[str] = mapped_column( |
256 | | - "category", sa.String(length=32), nullable=False, server_default=sa.text("'lifecycle'") |
| 256 | + category: Mapped[RouteHandlerCategory] = mapped_column( |
| 257 | + "category", |
| 258 | + StrEnumType(RouteHandlerCategory), |
| 259 | + nullable=False, |
| 260 | + server_default=sa.text("'lifecycle'"), |
257 | 261 | ) |
258 | 262 | phase: Mapped[str] = mapped_column("phase", sa.String(length=64), nullable=False) |
259 | 263 | from_status: Mapped[str | None] = mapped_column( |
260 | 264 | "from_status", sa.String(length=64), nullable=True |
261 | 265 | ) |
262 | 266 | to_status: Mapped[str | None] = mapped_column("to_status", sa.String(length=64), nullable=True) |
263 | | - from_health_status: Mapped[str | None] = mapped_column( |
264 | | - "from_health_status", sa.String(length=64), nullable=True |
| 267 | + from_sub_status: Mapped[str | None] = mapped_column( |
| 268 | + "from_sub_status", sa.String(length=64), nullable=True |
265 | 269 | ) |
266 | | - to_health_status: Mapped[str | None] = mapped_column( |
267 | | - "to_health_status", sa.String(length=64), nullable=True |
| 270 | + to_sub_status: Mapped[str | None] = mapped_column( |
| 271 | + "to_sub_status", sa.String(length=64), nullable=True |
268 | 272 | ) |
269 | 273 |
|
270 | 274 | result: Mapped[str] = mapped_column("result", sa.String(length=32), nullable=False) |
@@ -296,37 +300,23 @@ class RouteHistoryRow(Base): # type: ignore[misc] |
296 | 300 | ) |
297 | 301 |
|
298 | 302 | def should_merge_with(self, new_row: RouteHistoryRow) -> bool: |
299 | | - """Check if a new entry should be merged with this one. |
300 | | -
|
301 | | - Merge conditions: |
302 | | - - Same category, phase, error_code |
303 | | - - For lifecycle category: same to_status |
304 | | - - For health category: same to_health_status |
305 | | - """ |
306 | | - if self.category != new_row.category: |
307 | | - return False |
308 | | - if self.phase != new_row.phase or self.error_code != new_row.error_code: |
309 | | - return False |
310 | | - if self.category == "health": |
311 | | - return self.to_health_status == new_row.to_health_status |
312 | | - return self.to_status == new_row.to_status |
| 303 | + return ( |
| 304 | + self.category == new_row.category |
| 305 | + and self.phase == new_row.phase |
| 306 | + and self.error_code == new_row.error_code |
| 307 | + ) |
313 | 308 |
|
314 | 309 | def to_data(self) -> RouteHistoryData: |
315 | | - # API exposes unified from_status/to_status based on category |
316 | | - if self.category == "health": |
317 | | - from_val = self.from_health_status |
318 | | - to_val = self.to_health_status |
319 | | - else: |
320 | | - from_val = self.from_status |
321 | | - to_val = self.to_status |
322 | 310 | return RouteHistoryData( |
323 | 311 | id=self.id, |
324 | 312 | route_id=self.route_id, |
325 | 313 | deployment_id=self.deployment_id, |
326 | 314 | category=self.category, |
327 | 315 | phase=self.phase, |
328 | | - from_status=from_val, |
329 | | - to_status=to_val, |
| 316 | + from_status=self.from_status, |
| 317 | + to_status=self.to_status, |
| 318 | + from_sub_status=self.from_sub_status, |
| 319 | + to_sub_status=self.to_sub_status, |
330 | 320 | result=SchedulingResult(self.result), |
331 | 321 | error_code=self.error_code, |
332 | 322 | message=self.message, |
|
0 commit comments