@@ -2532,7 +2532,7 @@ async def _get_source_api(self, url, controller_name=None):
25322532
25332533 async def wait_for_idle (self , apps = None , raise_on_error = True , raise_on_blocked = False ,
25342534 wait_for_active = False , timeout = 10 * 60 , idle_period = 15 , check_freq = 0.5 ,
2535- status = None , wait_for_units = 1 , wait_for_exact_units = - 1 ):
2535+ status = None , wait_for_units = 1 , wait_for_exact_units = None ):
25362536 """Wait for applications in the model to settle into an idle state.
25372537
25382538 :param apps (list[str]): Optional list of specific app names to wait on.
@@ -2574,8 +2574,7 @@ async def wait_for_idle(self, apps=None, raise_on_error=True, raise_on_blocked=F
25742574
25752575 :param wait_for_exact_units (int): The exact number of units to be expected before
25762576 going into the idle state. (e.g. useful for scaling down).
2577- The default is -1 unit.
2578- When positive, takes precedence over the `wait_for_units` parameter.
2577+ When set, takes precedence over the `wait_for_units` parameter.
25792578 """
25802579 if wait_for_active :
25812580 warnings .warn ("wait_for_active is deprecated; use status" , DeprecationWarning )
@@ -2606,6 +2605,10 @@ def _raise_for_status(entities, status):
26062605 ", " .join (errored ),
26072606 ))
26082607
2608+ if wait_for_exact_units is not None :
2609+ assert type (wait_for_exact_units ) == int and wait_for_exact_units >= 0 , \
2610+ f'Invalid value for wait_for_exact_units { wait_for_exact_units } '
2611+
26092612 while True :
26102613 busy = []
26112614 errors = {}
@@ -2619,7 +2622,7 @@ def _raise_for_status(entities, status):
26192622 errors .setdefault ("App" , []).append (app .name )
26202623 if raise_on_blocked and app .status == "blocked" :
26212624 blocks .setdefault ("App" , []).append (app .name )
2622- if wait_for_exact_units > 0 :
2625+ if wait_for_exact_units is not None :
26232626 if len (app .units ) != wait_for_exact_units :
26242627 busy .append (app .name + " (waiting for exactly %s units, current : %s)" %
26252628 (wait_for_exact_units , len (app .units )))
0 commit comments