diff --git a/conf/stack.ini b/conf/stack.ini index 9403fc79..28bb2f3f 100644 --- a/conf/stack.ini +++ b/conf/stack.ini @@ -37,6 +37,11 @@ syslog = 0 # Which run type to use [fork (the default), upstart, screen] run_type = fork +# How many seconds to wait until a service comes online before using it. +# For example, before uploading to glance we need keystone and glance to be online. +# Sometimes this takes 5 to 10 seconds to start these up.... +service_wait_seconds = 5 + [upstart] # These flags are used for starting components under upstart (if default/run_type is upstart) diff --git a/devstack/components/db.py b/devstack/components/db.py index 97d53876..5044bdb2 100644 --- a/devstack/components/db.py +++ b/devstack/components/db.py @@ -17,7 +17,6 @@ from devstack import component as comp from devstack import exceptions as excp from devstack import log as logging -from devstack import settings from devstack import shell as sh from devstack import utils @@ -25,9 +24,6 @@ import abc LOG = logging.getLogger("devstack.components.db") -# How long we wait before using the database after a restart -START_WAIT_TIME = settings.WAIT_ALIVE_SECS - # Need to reset pw to blank since this distributions don't seem to # always reset it when u uninstall the db RESET_BASE_PW = '' @@ -158,6 +154,7 @@ class DBInstaller(comp.PkgInstallComponent): class DBRuntime(comp.EmptyRuntime): def __init__(self, *args, **kargs): comp.EmptyRuntime.__init__(self, *args, **kargs) + self.wait_time = max(self.cfg.getint('default', 'service_wait_seconds'), 1) def _get_run_actions(self, act, exception_cls): dbtype = self.cfg.get("db", "type") @@ -173,8 +170,8 @@ class DBRuntime(comp.EmptyRuntime): sh.execute(*startcmd, run_as_root=True, check_exit_code=True) - LOG.info("Please wait %s seconds while it starts up." % START_WAIT_TIME) - sh.sleep(START_WAIT_TIME) + LOG.info("Please wait %s seconds while it starts up." % self.wait_time) + sh.sleep(self.wait_time) return 1 else: return 0 @@ -195,8 +192,8 @@ class DBRuntime(comp.EmptyRuntime): sh.execute(*restartcmd, run_as_root=True, check_exit_code=True) - LOG.info("Please wait %s seconds while it restarts." % START_WAIT_TIME) - sh.sleep(START_WAIT_TIME) + LOG.info("Please wait %s seconds while it restarts." % self.wait_time) + sh.sleep(self.wait_time) return 1 def status(self): diff --git a/devstack/components/glance.py b/devstack/components/glance.py index 71c55d0e..cf24965c 100644 --- a/devstack/components/glance.py +++ b/devstack/components/glance.py @@ -19,7 +19,6 @@ import io from devstack import cfg from devstack import component as comp from devstack import log as logging -from devstack import settings from devstack import shell as sh from devstack.components import db @@ -53,9 +52,6 @@ GSCR = 'scrub' # This db will be dropped and created DB_NAME = "glance" -# How long to wait before attempting image upload -WAIT_ONLINE_TO = settings.WAIT_ALIVE_SECS - # What applications to start APP_OPTIONS = { 'glance-api': ['--config-file', sh.joinpths('%ROOT%', "etc", API_CONF)], @@ -187,6 +183,7 @@ class GlanceRuntime(comp.PythonRuntime): comp.PythonRuntime.__init__(self, *args, **kargs) self.cfg_dir = sh.joinpths(self.app_dir, CONFIG_DIR) self.bin_dir = sh.joinpths(self.app_dir, BIN_DIR) + self.wait_time = max(self.cfg.getint('default', 'service_wait_seconds'), 1) def known_subsystems(self): return SUB_TO_APP.keys() @@ -213,6 +210,6 @@ class GlanceRuntime(comp.PythonRuntime): else: # Install any images that need activating... # TODO: make this less cheesy - need to wait till glance goes online - LOG.info("Waiting %s seconds so that glance can start up before image install." % (WAIT_ONLINE_TO)) - sh.sleep(WAIT_ONLINE_TO) + LOG.info("Waiting %s seconds so that glance can start up before image install." % (self.wait_time)) + sh.sleep(self.wait_time) uploader.Service(self.cfg, self.pw_gen).install() diff --git a/devstack/components/keystone.py b/devstack/components/keystone.py index 8c82e0b3..c7d077bd 100644 --- a/devstack/components/keystone.py +++ b/devstack/components/keystone.py @@ -21,7 +21,6 @@ from urlparse import urlunparse from devstack import cfg from devstack import component as comp from devstack import log as logging -from devstack import settings from devstack import shell as sh from devstack import utils @@ -63,9 +62,6 @@ APP_OPTIONS = { } -# Used to wait until started before we can run the data setup script -WAIT_ONLINE_TO = settings.WAIT_ALIVE_SECS - # Swift template additions # TODO: get rid of these SWIFT_TEMPL_ADDS = ['catalog.RegionOne.object_store.publicURL = http://%SERVICE_HOST%:8080/v1/AUTH_$(tenant_id)s', @@ -206,6 +202,7 @@ class KeystoneRuntime(comp.PythonRuntime): comp.PythonRuntime.__init__(self, *args, **kargs) self.cfg_dir = sh.joinpths(self.app_dir, CONFIG_DIR) self.bin_dir = sh.joinpths(self.app_dir, BIN_DIR) + self.wait_time = max(self.cfg.getint('default', 'service_wait_seconds'), 1) def post_start(self): tgt_fn = sh.joinpths(self.bin_dir, MANAGE_DATA_CONF) @@ -213,8 +210,8 @@ class KeystoneRuntime(comp.PythonRuntime): # If its still there, run it # these environment additions are important # in that they eventually affect how this script runs - LOG.info("Waiting %s seconds so that keystone can start up before running first time init." % (WAIT_ONLINE_TO)) - sh.sleep(WAIT_ONLINE_TO) + LOG.info("Waiting %s seconds so that keystone can start up before running first time init." % (self.wait_time)) + sh.sleep(self.wait_time) env = dict() env['ENABLED_SERVICES'] = ",".join(self.instances.keys()) env['BIN_DIR'] = self.bin_dir diff --git a/devstack/components/melange.py b/devstack/components/melange.py index 82810bce..fdbf63a2 100644 --- a/devstack/components/melange.py +++ b/devstack/components/melange.py @@ -19,7 +19,6 @@ import io from devstack import cfg from devstack import component as comp from devstack import log as logging -from devstack import settings from devstack import shell as sh from devstack import utils @@ -57,9 +56,6 @@ APP_OPTIONS = { 'melange-server': ['--config-file', '%CFG_FILE%'], } -# Wait time before we try to init melanges cidr (waiting for the server to start...) -WAIT_ONLINE_TO = settings.WAIT_ALIVE_SECS - class MelangeUninstaller(comp.PythonUninstallComponent): def __init__(self, *args, **kargs): @@ -137,6 +133,7 @@ class MelangeRuntime(comp.PythonRuntime): comp.PythonRuntime.__init__(self, *args, **kargs) self.bin_dir = sh.joinpths(self.app_dir, BIN_DIR) self.cfg_dir = sh.joinpths(self.app_dir, *CFG_LOC) + self.wait_time = max(self.cfg.getint('default', 'service_wait_seconds'), 1) def _get_apps_to_start(self): apps = list() @@ -161,8 +158,8 @@ class MelangeRuntime(comp.PythonRuntime): def post_start(self): comp.PythonRuntime.post_start(self) if "create-cidr" in self.options: - LOG.info("Waiting %s seconds so that the melange server can start up before cidr range creation." % (WAIT_ONLINE_TO)) - sh.sleep(WAIT_ONLINE_TO) + LOG.info("Waiting %s seconds so that the melange server can start up before cidr range creation." % (self.wait_time)) + sh.sleep(self.wait_time) mp = dict() mp['CIDR_RANGE'] = self.cfg.getdefaulted('melange', 'm_mac_range', DEF_CIDR_RANGE) utils.execute_template(*CIDR_CREATE_CMD, params=mp) diff --git a/devstack/components/nova.py b/devstack/components/nova.py index 9f3e9b80..5178ad3b 100644 --- a/devstack/components/nova.py +++ b/devstack/components/nova.py @@ -21,7 +21,6 @@ from devstack import date from devstack import exceptions from devstack import libvirt as virsh from devstack import log as logging -from devstack import settings from devstack import shell as sh from devstack import utils @@ -199,9 +198,6 @@ STD_COMPUTE_EXTS = 'nova.api.openstack.compute.contrib.standard_extensions' # Config keys we warm up so u won't be prompted later WARMUP_PWS = [('rabbit', rabbit.PW_USER_PROMPT)] -# Used to wait until started before we can run the data setup script -WAIT_ONLINE_TO = settings.WAIT_ALIVE_SECS - # Nova conf default section NV_CONF_DEF_SECTION = "[DEFAULT]" @@ -403,6 +399,7 @@ class NovaRuntime(comp.PythonRuntime): comp.PythonRuntime.__init__(self, *args, **kargs) self.cfg_dir = sh.joinpths(self.app_dir, CONFIG_DIR) self.bin_dir = sh.joinpths(self.app_dir, BIN_DIR) + self.wait_time = max(self.cfg.getint('default', 'service_wait_seconds'), 1) def _setup_network_init(self): tgt_fn = sh.joinpths(self.bin_dir, NET_INIT_CONF) @@ -412,8 +409,8 @@ class NovaRuntime(comp.PythonRuntime): # these environment additions are important # in that they eventually affect how this script runs if 'quantum' in self.options: - LOG.info("Waiting %s seconds so that quantum can start up before running first time init." % (WAIT_ONLINE_TO)) - sh.sleep(WAIT_ONLINE_TO) + LOG.info("Waiting %s seconds so that quantum can start up before running first time init." % (self.wait_time)) + sh.sleep(self.wait_time) env = dict() env['ENABLED_SERVICES'] = ",".join(self.instances.keys()) setup_cmd = NET_INIT_CMD_ROOT + [tgt_fn] diff --git a/devstack/components/rabbit.py b/devstack/components/rabbit.py index 134e2f79..9611d9ee 100644 --- a/devstack/components/rabbit.py +++ b/devstack/components/rabbit.py @@ -18,7 +18,6 @@ from tempfile import TemporaryFile from devstack import component as comp from devstack import log as logging -from devstack import settings from devstack import shell as sh LOG = logging.getLogger("devstack.components.rabbit") @@ -33,9 +32,6 @@ PWD_CMD = ['rabbitmqctl', 'change_password', 'guest'] # Default password (guest) RESET_BASE_PW = '' -# How long we wait for rabbitmq to start up before doing commands on it -WAIT_ON_TIME = settings.WAIT_ALIVE_SECS - # Config keys we warm up so u won't be prompted later WARMUP_PWS = ['rabbit'] @@ -85,6 +81,7 @@ class RabbitInstaller(comp.PkgInstallComponent): class RabbitRuntime(comp.EmptyRuntime): def __init__(self, *args, **kargs): comp.EmptyRuntime.__init__(self, *args, **kargs) + self.wait_time = max(self.cfg.getint('default', 'service_wait_seconds'), 1) def start(self): if self.status() != comp.STATUS_STARTED: @@ -132,8 +129,8 @@ class RabbitRuntime(comp.EmptyRuntime): def restart(self): LOG.info("Restarting rabbit-mq.") self._run_cmd(RESTART_CMD) - LOG.info("Please wait %s seconds while it starts up." % (WAIT_ON_TIME)) - sh.sleep(WAIT_ON_TIME) + LOG.info("Please wait %s seconds while it starts up." % (self.wait_time)) + sh.sleep(self.wait_time) return 1 def stop(self): diff --git a/devstack/image/uploader.py b/devstack/image/uploader.py index d229b06a..d46b54c4 100644 --- a/devstack/image/uploader.py +++ b/devstack/image/uploader.py @@ -215,7 +215,7 @@ class Image(object): continue LOG.debug("Checking if you already have an image named %r" % (name)) if self._registry.has_image(name): - LOG.warn("You already 'seem' to have image named %r, skipping that install..." % (name)) + LOG.warn("You already 'seem' to have image named %r, skipping its install..." % (name)) found_name = True break if not found_name: @@ -226,8 +226,11 @@ class Image(object): locations = Unpacker().unpack(url_fn, fetch_fn, tdir) tgt_image_name = self._generate_img_name(url_fn) self._register(tgt_image_name, locations) + return tgt_image_name finally: sh.deldir(tdir) + else: + return None class Registry: @@ -345,8 +348,10 @@ class Service: token = self._get_token() for url in urls: try: - Image(url, token).install() - am_installed += 1 + name = Image(url, token).install() + if name: + LOG.info("Installed image named %r" % (name)) + am_installed += 1 except (IOError, tarfile.TarError) as e: LOG.exception('Installing %r failed due to: %s', url, e) return am_installed diff --git a/devstack/libvirt.py b/devstack/libvirt.py index c2b3cfb5..e8a31fe2 100644 --- a/devstack/libvirt.py +++ b/devstack/libvirt.py @@ -16,7 +16,6 @@ from devstack import exceptions as excp from devstack import log as logging -from devstack import settings from devstack import shell as sh from devstack import utils @@ -55,7 +54,8 @@ _DEAD = 'DEAD' _ALIVE = 'ALIVE' # Alive wait time, just a sleep we put into so that the service can start up -WAIT_ALIVE_TIME = settings.WAIT_ALIVE_SECS +# FIXME: take from config... +WAIT_ALIVE_TIME = 5 def _get_virt_lib(): diff --git a/devstack/runners/screen.py b/devstack/runners/screen.py index 205c040f..618e672e 100644 --- a/devstack/runners/screen.py +++ b/devstack/runners/screen.py @@ -17,7 +17,6 @@ import json import re import tempfile -import time from devstack import date from devstack import exceptions as excp @@ -62,9 +61,6 @@ SCREEN_KILLER = ['screen', '-X', '-S', '%SCREEN_ID%', 'quit'] SCREEN_SOCKET_DIR_NAME = "devstack-screen-sockets" SCREEN_SOCKET_PERM = 0700 -# Used to wait until started before we can run the actual start cmd -WAIT_ONLINE_TO = settings.WAIT_ALIVE_SECS - # Run screen as root? ROOT_GO = True @@ -76,6 +72,7 @@ class ScreenRunner(base.RunnerBase): def __init__(self, cfg, component_name, trace_dir): base.RunnerBase.__init__(self, cfg, component_name, trace_dir) self.socket_dir = sh.joinpths(tempfile.gettempdir(), SCREEN_SOCKET_DIR_NAME) + self.wait_time = max(self.cfg.getint('default', 'service_wait_seconds'), 1) def stop(self, app_name): trace_fn = tr.trace_fn(self.trace_dir, SCREEN_TEMPL % (app_name)) @@ -161,8 +158,8 @@ class ScreenRunner(base.RunnerBase): shell=True, run_as_root=ROOT_GO, env_overrides=self._get_env()) - LOG.debug("Waiting %s seconds before we attempt to set the title bar for that session." % (WAIT_ONLINE_TO)) - time.sleep(WAIT_ONLINE_TO) + LOG.debug("Waiting %s seconds before we attempt to set the title bar for that session." % (self.wait_time)) + sh.sleep(self.wait_time) bar_init_cmd = self._gen_cmd(BAR_INIT) sh.execute(*bar_init_cmd, shell=True, @@ -182,8 +179,8 @@ class ScreenRunner(base.RunnerBase): shell=True, run_as_root=ROOT_GO, env_overrides=self._get_env()) - LOG.debug("Waiting %s seconds before we attempt to run command [%s] in that window." % (WAIT_ONLINE_TO, run_cmd)) - time.sleep(WAIT_ONLINE_TO) + LOG.debug("Waiting %s seconds before we attempt to run command [%s] in that window." % (self.wait_time, run_cmd)) + sh.sleep(self.wait_time) start_cmd = self._gen_cmd(CMD_START, mp) sh.execute(*start_cmd, shell=True, diff --git a/devstack/settings.py b/devstack/settings.py index 5f0c709f..850433ae 100644 --- a/devstack/settings.py +++ b/devstack/settings.py @@ -24,9 +24,6 @@ PROG_NICE_NAME = "DEVSTACKpy" IPV4 = 'IPv4' IPV6 = 'IPv6' -# How long to wait for a service to startup -WAIT_ALIVE_SECS = 5 - # Different run types supported RUN_TYPE_FORK = "FORK" RUN_TYPE_UPSTART = "UPSTART"