Merge ~asbalderson/juju-wait:maintain-default-behavior into juju-wait:master

Proposed by Alexander Balderson
Status: Merged
Merged at revision: e83dfe3d132fed7fce694bf43787cf02e8d60864
Proposed branch: ~asbalderson/juju-wait:maintain-default-behavior
Merge into: juju-wait:master
Diff against target: 55 lines (+10/-8)
1 file modified
juju_wait/__init__.py (+10/-8)
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Jason Hobbs (community) Approve
Review via email: mp+378306@code.launchpad.net

Commit message

Maintain orignal success regardless of machine status

Set the defaults for pending and error timeout to 0, and add
fucntionality so that 0 timeout does not set ready to False.

To post a comment you must log in.
Revision history for this message
Jason Hobbs (jason-hobbs) wrote :

+1. Some background, in our testing, this flagged a failure on a machine that didn't really have any issues other than juju leaving it in 'down' for a while on its way up.

review: Approve
Revision history for this message
Stuart Bishop (stub) wrote :

Ta. The new feature should have been backwards compatible to begin with. Bugfix release coming shortly.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/juju_wait/__init__.py b/juju_wait/__init__.py
index d40a59b..f88a463 100755
--- a/juju_wait/__init__.py
+++ b/juju_wait/__init__.py
@@ -270,7 +270,7 @@ def wait_cmd(args=sys.argv[1:]):
270 dest="machine_error_timeout",270 dest="machine_error_timeout",
271 type=int,271 type=int,
272 action="store",272 action="store",
273 default=300,273 default=0,
274 help="Time for a machine to be in a bad state before exiting (seconds).",274 help="Time for a machine to be in a bad state before exiting (seconds).",
275 )275 )
276 parser.add_argument(276 parser.add_argument(
@@ -278,7 +278,7 @@ def wait_cmd(args=sys.argv[1:]):
278 dest="machine_pending_timeout",278 dest="machine_pending_timeout",
279 type=int,279 type=int,
280 action="store",280 action="store",
281 default=3600,281 default=0,
282 help="Time for a machine to be in a pending state before exiting (seconds).",282 help="Time for a machine to be in a pending state before exiting (seconds).",
283 )283 )
284 parser.add_argument("--version", default=False, action="store_true")284 parser.add_argument("--version", default=False, action="store_true")
@@ -367,8 +367,8 @@ def wait(
367 max_wait=None,367 max_wait=None,
368 retry_errors=0,368 retry_errors=0,
369 exclude=None,369 exclude=None,
370 machine_error_timeout=300,370 machine_error_timeout=0,
371 machine_pending_timeout=3600,371 machine_pending_timeout=0,
372 machine_exclude=None,372 machine_exclude=None,
373):373):
374 # Note that wait_for_workload is only useful as a workaround for374 # Note that wait_for_workload is only useful as a workaround for
@@ -586,15 +586,17 @@ def wait(
586 logging.debug("Ignoring machine {} because it is excluded".format(machine))586 logging.debug("Ignoring machine {} because it is excluded".format(machine))
587 continue587 continue
588 if state.state in MACHINE_ERROR_STATES:588 if state.state in MACHINE_ERROR_STATES:
589 ready = False
590 logging.debug("Machine {} is in {}".format(machine, state.state))589 logging.debug("Machine {} is in {}".format(machine, state.state))
591 if loop_starttime - state.time.timestamp() > machine_error_timeout:590 if machine_error_timeout > 0:
591 ready = False
592 if machine_error_timeout > 0 and loop_starttime - state.time.timestamp() > machine_error_timeout:
592 minutes = round((loop_starttime - state.time.timestamp()) / 60)593 minutes = round((loop_starttime - state.time.timestamp()) / 60)
593 logging.error("Machine {} is in {} for {} minutes.".format(machine, state.state, minutes))594 logging.error("Machine {} is in {} for {} minutes.".format(machine, state.state, minutes))
594 raise JujuWaitException(1)595 raise JujuWaitException(1)
595 if state.state in MACHINE_PENDING_STATES:596 if state.state in MACHINE_PENDING_STATES:
596 ready = False597 if machine_pending_timeout > 0:
597 if loop_starttime - state.time.timestamp() > machine_pending_timeout:598 ready = False
599 if machine_pending_timeout > 0 and loop_starttime - state.time.timestamp() > machine_pending_timeout:
598 minutes = round((loop_starttime - state.time.timestamp()) / 60)600 minutes = round((loop_starttime - state.time.timestamp()) / 60)
599 logging.error("Machine {} has been pending for {} minutes".format(machine, minutes))601 logging.error("Machine {} has been pending for {} minutes".format(machine, minutes))
600 raise JujuWaitException(1)602 raise JujuWaitException(1)

Subscribers

People subscribed via source and target branches

to all changes: