diff --git a/charmhelpers/contrib/hahelpers/cluster.py b/charmhelpers/contrib/hahelpers/cluster.py index ba34fba0c..ad120b48c 100644 --- a/charmhelpers/contrib/hahelpers/cluster.py +++ b/charmhelpers/contrib/hahelpers/cluster.py @@ -404,11 +404,25 @@ def distributed_wait(modulo=None, wait=None, operation_name='operation'): # will still wait calculated_wait = modulo_distribution(modulo=modulo, wait=wait, non_zero_wait=True) - msg = "Waiting {} seconds for {} ...".format(calculated_wait, - operation_name) - log(msg, DEBUG) - status_set('maintenance', msg) - time.sleep(calculated_wait) + + # update status every 60 seconds with wait time elapsed + remaining_wait = calculated_wait + elapsed = 0 + while remaining_wait: + if elapsed == 0: + msg = "Waiting {} seconds for {} ...".format(calculated_wait, + operation_name) + else: + msg = ("Waiting {} seconds for {} ..." + "elapsed: {} seconds".format(calculated_wait, + operation_name, + elapsed)) + log(msg, DEBUG) + status_set('maintenance', msg) + next_sleep = max(remaining_wait, 60) + time.sleep(next_sleep) + elapsed += next_sleep + remaining_wait = calculated_wait - elapsed def get_managed_services_and_ports(services, external_ports, diff --git a/tests/contrib/hahelpers/test_cluster_utils.py b/tests/contrib/hahelpers/test_cluster_utils.py index 990f1dcb0..6084966b2 100644 --- a/tests/contrib/hahelpers/test_cluster_utils.py +++ b/tests/contrib/hahelpers/test_cluster_utils.py @@ -531,7 +531,7 @@ def test_distributed_wait(self, log, modulo_distribution, sleep, is_leader.return_value = True cluster_utils.distributed_wait(modulo=9, wait=23) modulo_distribution.assert_not_called() - sleep.assert_called_with(0) + sleep.assert_not_called(0) # The rest of the tests are non-leader units is_leader.return_value = False