Skip to content

Commit 6640174

Browse files
committed
Try making logic clearer
1 parent c314b76 commit 6640174

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

juju/model.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,10 +2568,11 @@ def _raise_for_status(entities, status):
25682568
# individual units, another one for waiting for an application.
25692569
# The convoluted logic below is the result of trying to do both at the same
25702570
# time
2571-
need_to_wait_more_for_a_particular_status = status and unit.workload_status != status
2571+
need_to_wait_more_for_a_particular_status = status and (unit.workload_status != status)
2572+
app_is_in_desired_status = (not status) or (app_status == status)
25722573
if not need_to_wait_more_for_a_particular_status and \
25732574
unit.agent_status == "idle" and \
2574-
(wait_for_units or (not status or app_status == status)):
2575+
(wait_for_units or app_is_in_desired_status):
25752576
# A unit is ready if either:
25762577
# 1) Don't need to wait more for a particular status and the agent is "idle"
25772578
# 2) We're looking for a particular status and the unit's workload,
@@ -2581,7 +2582,7 @@ def _raise_for_status(entities, status):
25812582
# (because e.g. app can be in 'waiting' while unit.0 is 'active' and unit.1
25822583
# is 'waiting')
25832584

2584-
# The unit is ready, start measuring the time period that
2585+
# Either way, the unit is ready, start measuring the time period that
25852586
# it needs to stay in that state (i.e. idle_period)
25862587
units_ready.add(unit.name)
25872588
now = datetime.now()

0 commit comments

Comments
 (0)