@@ -199,20 +199,9 @@ async def _cleanup_failed_branch_deployment(branch_id: Identifier) -> None:
199199def _should_update_branch_status (
200200 current : BranchServiceStatus ,
201201 derived : BranchServiceStatus ,
202- * ,
203- resize_in_progress : bool = True ,
204202) -> bool :
205203 if current == derived :
206204 return False
207- if current == BranchServiceStatus .RESIZING :
208- if not resize_in_progress :
209- return derived in {
210- BranchServiceStatus .ACTIVE_HEALTHY ,
211- BranchServiceStatus .ACTIVE_UNHEALTHY ,
212- BranchServiceStatus .STOPPED ,
213- BranchServiceStatus .ERROR ,
214- }
215- return derived == BranchServiceStatus .ERROR
216205 if current == BranchServiceStatus .STARTING and derived == BranchServiceStatus .STOPPED :
217206 logger .debug ("Ignoring STARTING -> STOPPED transition detected by branch status monitor" )
218207 return False
@@ -287,12 +276,22 @@ async def refresh_branch_status(branch_id: Identifier) -> BranchServiceStatus:
287276 return new_status
288277
289278
290- async def _refresh_branch_status (branch : Branch ) -> BranchServiceStatus :
279+ def _active_task_status (branch : Branch ) -> BranchServiceStatus | None :
280+ """Return the in-progress status for the running task, or None if idle."""
291281 if branch .control_task_id is not None :
292282 result = perform_control .AsyncResult (str (branch .control_task_id ))
293283 action = (result .kwargs or {}).get ("action" )
294284 if action in _CONTROL_TRANSITION_INITIAL :
295285 return _CONTROL_TRANSITION_INITIAL [action ]
286+ if branch .resize_task_id is not None :
287+ return BranchServiceStatus .RESIZING
288+ return None
289+
290+
291+ async def _refresh_branch_status (branch : Branch ) -> BranchServiceStatus :
292+ in_progress = _active_task_status (branch )
293+ if in_progress is not None :
294+ return in_progress
296295
297296 current_status = _parse_branch_status (branch .status )
298297 status = deployment_status (branch .id )
@@ -303,8 +302,7 @@ async def _refresh_branch_status(branch: Branch) -> BranchServiceStatus:
303302 status ,
304303 )
305304
306- resize_in_progress = branch .resize_task_id is not None
307- if _should_update_branch_status (current_status , status , resize_in_progress = resize_in_progress ):
305+ if _should_update_branch_status (current_status , status ):
308306 branch .set_status (status )
309307 return status
310308
@@ -1879,7 +1877,6 @@ async def resize(
18791877
18801878 task_id = dispatch_resize (str (branch .id ), dict (effective_parameters ))
18811879
1882- branch .set_status (BranchServiceStatus .RESIZING )
18831880 branch .resize_task_id = task_id
18841881 await session .commit ()
18851882
0 commit comments