@@ -200,20 +200,9 @@ async def _cleanup_failed_branch_deployment(branch_id: Identifier) -> None:
200200def _should_update_branch_status (
201201 current : BranchServiceStatus ,
202202 derived : BranchServiceStatus ,
203- * ,
204- resize_in_progress : bool = True ,
205203) -> bool :
206204 if current == derived :
207205 return False
208- if current == BranchServiceStatus .RESIZING :
209- if not resize_in_progress :
210- return derived in {
211- BranchServiceStatus .ACTIVE_HEALTHY ,
212- BranchServiceStatus .ACTIVE_UNHEALTHY ,
213- BranchServiceStatus .STOPPED ,
214- BranchServiceStatus .ERROR ,
215- }
216- return derived == BranchServiceStatus .ERROR
217206 if current == BranchServiceStatus .STARTING and derived == BranchServiceStatus .STOPPED :
218207 logger .debug ("Ignoring STARTING -> STOPPED transition detected by branch status monitor" )
219208 return False
@@ -288,12 +277,22 @@ async def refresh_branch_status(branch_id: Identifier) -> BranchServiceStatus:
288277 return new_status
289278
290279
291- async def _refresh_branch_status (branch : Branch ) -> BranchServiceStatus :
280+ def _active_task_status (branch : Branch ) -> BranchServiceStatus | None :
281+ """Return the in-progress status for the running task, or None if idle."""
292282 if branch .control_task_id is not None :
293283 result = perform_control .AsyncResult (str (branch .control_task_id ))
294284 action = (result .kwargs or {}).get ("action" )
295285 if action in _CONTROL_TRANSITION_INITIAL :
296286 return _CONTROL_TRANSITION_INITIAL [action ]
287+ if branch .resize_task_id is not None :
288+ return BranchServiceStatus .RESIZING
289+ return None
290+
291+
292+ async def _refresh_branch_status (branch : Branch ) -> BranchServiceStatus :
293+ in_progress = _active_task_status (branch )
294+ if in_progress is not None :
295+ return in_progress
297296
298297 current_status = _parse_branch_status (branch .status )
299298 status = deployment_status (branch .id )
@@ -304,8 +303,7 @@ async def _refresh_branch_status(branch: Branch) -> BranchServiceStatus:
304303 status ,
305304 )
306305
307- resize_in_progress = branch .resize_task_id is not None
308- if _should_update_branch_status (current_status , status , resize_in_progress = resize_in_progress ):
306+ if _should_update_branch_status (current_status , status ):
309307 branch .set_status (status )
310308 return status
311309
@@ -1898,7 +1896,6 @@ async def resize(
18981896
18991897 task_id = dispatch_resize (str (branch .id ), dict (effective_parameters ))
19001898
1901- branch .set_status (BranchServiceStatus .RESIZING )
19021899 branch .resize_task_id = task_id
19031900 await session .commit ()
19041901
0 commit comments