From 0ee9371f0c67d2334ced2a5bec171864a4fa7374 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 17 Oct 2012 13:37:57 +0100 Subject: [PATCH] heat engine : Make wait-condition poll interval better Remove rising-rate sleep-time logic and replace with a bounded poll interval derived from the timeout - this should avoid ramping up to a really long interval and delaying stack complete status Fixes #264 Change-Id: Id53b87a988299708c29fc853f2801f527fd825dd Signed-off-by: Steven Hardy --- heat/engine/wait_condition.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/heat/engine/wait_condition.py b/heat/engine/wait_condition.py index 179a467f84..fe55fa71cd 100644 --- a/heat/engine/wait_condition.py +++ b/heat/engine/wait_condition.py @@ -65,12 +65,22 @@ class WaitCondition(resources.Resource): 'Count': {'Type': 'Number', 'MinValue': '1'}} + # Sleep time between polling for wait completion + # is calculated as a fraction of timeout time + # bounded by MIN_SLEEP and MAX_SLEEP + MIN_SLEEP = 1 # seconds + MAX_SLEEP = 10 + SLEEP_DIV = 100 # 1/100'th of timeout + def __init__(self, name, json_snippet, stack): super(WaitCondition, self).__init__(name, json_snippet, stack) self.resource_id = None self.timeout = int(self.t['Properties']['Timeout']) self.count = int(self.t['Properties'].get('Count', '1')) + self.sleep_time = max(min(self.MAX_SLEEP, + self.timeout / self.SLEEP_DIV), + self.MIN_SLEEP) def _get_handle_resource_id(self): if self.resource_id is None: @@ -95,14 +105,14 @@ class WaitCondition(resources.Resource): handle = self.stack[self._get_handle_resource_id()] (status, reason) = (WAITING, '') - sleep_time = 1 while status == WAITING: (status, reason) = self._get_status_reason(handle) if status == WAITING: - logger.debug('Waiting for the Metadata[Status]') - eventlet.sleep(sleep_time) - sleep_time = min(sleep_time * 2, self.timeout / 4) + logger.debug('Polling for WaitCondition completion,' + + ' sleeping for %s seconds, timeout %s' % + (self.sleep_time, self.timeout)) + eventlet.sleep(self.sleep_time) except eventlet.Timeout as t: if t is not tmo: