Remove wait sleep time and use the runtime status to see if its up

This commit is contained in:
Joshua Harlow 2012-08-28 13:34:39 -07:00
parent f5136eeddb
commit d7ad32c4d5
4 changed files with 29 additions and 7 deletions

View File

@ -531,6 +531,32 @@ class ProgramRuntime(component.Component):
def stop(self):
return 0
def wait_active(self, between_wait=1, max_attempts=5):
rt_name = self.name
num_started = len(self.apps_to_start)
if not num_started:
raise excp.StartException("No %r programs started, can not wait for them to become active..." % (rt_name))
def waiter(try_num):
LOG.info("Waiting %s seconds for component %s programs to start.", between_wait, colorizer.quote(rt_name))
LOG.info("Please wait...")
sh.sleep(between_wait)
for i in range(0, max_attempts):
statii = self.status()
if len(statii) == num_started:
not_worked = []
for p_status in statii:
if p_status.status != STATUS_STARTED:
not_worked.append(p_status)
if len(not_worked) == 0:
return
waiter(i + 1)
tot_time = max(0, between_wait * max_attempts)
raise excp.StartException("Failed waiting %s seconds for component %r programs to become active..."
% (tot_time, rt_name))
class EmptyRuntime(ProgramRuntime):
pass

View File

@ -198,7 +198,6 @@ class GlanceRuntime(comp.PythonRuntime):
def __init__(self, *args, **kargs):
comp.PythonRuntime.__init__(self, *args, **kargs)
self.bin_dir = sh.joinpths(self.get_option('app_dir'), 'bin')
self.wait_time = self.get_int_option('service_wait_seconds')
@property
def apps_to_start(self):
@ -224,8 +223,7 @@ class GlanceRuntime(comp.PythonRuntime):
comp.PythonRuntime.post_start(self)
if self.get_bool_option('load-images'):
# Install any images that need activating...
LOG.info("Waiting %s seconds so that glance can start up before image install." % (self.wait_time))
sh.sleep(self.wait_time)
self.wait_active()
params = {}
params['glance'] = ghelper.get_shared_params(**self.options)
params['keystone'] = khelper.get_shared_params(ip=self.get_option('ip'),

View File

@ -196,7 +196,6 @@ class KeystoneRuntime(comp.PythonRuntime):
def __init__(self, *args, **kargs):
comp.PythonRuntime.__init__(self, *args, **kargs)
self.bin_dir = sh.joinpths(self.get_option('app_dir'), 'bin')
self.wait_time = self.get_int_option('service_wait_seconds')
self.init_fn = sh.joinpths(self.get_option('trace_dir'), INIT_WHAT_HAPPENED)
@ -214,8 +213,7 @@ class KeystoneRuntime(comp.PythonRuntime):
def post_start(self):
if not sh.isfile(self.init_fn) and self.get_bool_option('do-init'):
LOG.info("Waiting %s seconds so that keystone can start up before running first time init." % (self.wait_time))
sh.sleep(self.wait_time)
self.wait_active()
LOG.info("Running commands to initialize keystone.")
(fn, contents) = utils.load_template(self.name, INIT_WHAT_FN)
LOG.debug("Initializing with contents of %s", fn)

View File

@ -1,6 +1,6 @@
#!/bin/bash
# This script cleans up the system as part of a nova uninstall
# This script cleans up the system iptables/services as part of a nova uninstall
#
# It is best effort!
#