Skip to content

Commit a376d55

Browse files
committed
Rename wait_for_units param -> wait_for_at_least_units
to make the semantics of `wait_for_units` explicit, which is to wait for a certain amount of units across all the given applications and return when those are available, regardless of the state of the other units (they can be in an error state or whatever just don't care and return) Fixes #886
1 parent 434a080 commit a376d55

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

juju/model.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,7 +2622,7 @@ async def wait_for_idle(self, apps=None, raise_on_error=True, raise_on_blocked=F
26222622
warnings.warn("wait_for_active is deprecated; use status", DeprecationWarning)
26232623
status = "active"
26242624

2625-
_wait_for_units = wait_for_units if wait_for_units is not None else 1
2625+
_wait_for_units = wait_for_at_least_units if wait_for_at_least_units is not None else 1
26262626

26272627
timeout = timedelta(seconds=timeout) if timeout is not None else None
26282628
idle_period = timedelta(seconds=idle_period)
@@ -2689,10 +2689,11 @@ def _raise_for_status(entities, status):
26892689
busy.append(app.name + " (not enough units yet - %s/%s)" %
26902690
(len(app.units), _wait_for_units))
26912691
continue
2692-
# User wants to see a certain # of units, and we have enough
2693-
elif wait_for_units and len(units_ready) >= _wait_for_units:
2692+
# User is waiting for at least a certain # of units, and we have enough
2693+
elif wait_for_at_least_units and len(units_ready) >= _wait_for_units:
26942694
# So no need to keep looking, we have the desired number of units ready to go,
2695-
# exit the loop. Don't return, though, we might still have some errors to raise
2695+
# exit the loop. Don't just return here, though, we might still have some
2696+
# errors to raise at the end
26962697
break
26972698
for unit in app.units:
26982699
if unit.machine is not None and unit.machine.status == "error":
@@ -2711,7 +2712,8 @@ def _raise_for_status(entities, status):
27112712
if not waiting_for_a_particular_status and unit.agent_status == "idle":
27122713
# We'll be here in two cases:
27132714
# 1) We're not waiting for a particular status and the agent is "idle"
2714-
# 2) We're waiting for a particular status and the workload is in that status
2715+
# 2) We're waiting for a particular status and the workload is in that
2716+
# status
27152717
# Either way, the unit is ready, start measuring the time period that
27162718
# it needs to stay in that state (i.e. idle_period)
27172719
units_ready.add(unit.name)

0 commit comments

Comments
 (0)