]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Allow c-vol backends to start when some backends fail to load
authorEric Harney <eharney@redhat.com>
Mon, 21 Sep 2015 18:29:19 +0000 (14:29 -0400)
committerEric Harney <eharney@redhat.com>
Tue, 22 Sep 2015 15:50:44 +0000 (11:50 -0400)
Currently, if a c-vol backend fails to load due to an error in
the module startup process (like a volume driver's __init__ or
dependency import failure), the c-vol process halts completely.

Instead, catch that backend failure, log it, and allow other
backends in enabled_backends to still start up and run.

Note that this is not applicable for failures that allow
drivers to load and remain "uninitialized" -- this is for
failures that occur prior to that point.

Closes-Bug: #1497413

Change-Id: If183b9e3d21777cddf713c2dc88dc80ae7cfe01d

cinder/cmd/volume.py

index c07ea42fa80dadc88c4988f578241faea3d7d92a..c9877aefeddf2dd4deb73ea2741449d8130fe4f4 100644 (file)
@@ -42,6 +42,7 @@ i18n.enable_lazy()
 # Need to register global_opts
 from cinder.common import config  # noqa
 from cinder.db import api as session
+from cinder.i18n import _
 from cinder import service
 from cinder import utils
 from cinder import version
@@ -62,20 +63,36 @@ def main():
     utils.monkey_patch()
     gmr.TextGuruMeditation.setup_autorun(version)
     launcher = service.get_launcher()
+    LOG = logging.getLogger(__name__)
+    service_started = False
+
     if CONF.enabled_backends:
         for backend in CONF.enabled_backends:
             CONF.register_opt(host_opt, group=backend)
             backend_host = getattr(CONF, backend).backend_host
             host = "%s@%s" % (backend_host or CONF.host, backend)
-            server = service.Service.create(host=host,
-                                            service_name=backend,
-                                            binary='cinder-volume')
-            # Dispose of the whole DB connection pool here before
-            # starting another process.  Otherwise we run into cases where
-            # child processes share DB connections which results in errors.
-            session.dispose_engine()
-            launcher.launch_service(server)
+            try:
+                server = service.Service.create(host=host,
+                                                service_name=backend,
+                                                binary='cinder-volume')
+            except Exception:
+                msg = _('Volume service %s failed to start.') % host
+                LOG.exception(msg)
+            else:
+                # Dispose of the whole DB connection pool here before
+                # starting another process.  Otherwise we run into cases where
+                # child processes share DB connections which results in errors.
+                session.dispose_engine()
+                launcher.launch_service(server)
+                service_started = True
     else:
         server = service.Service.create(binary='cinder-volume')
         launcher.launch_service(server)
+        service_started = True
+
+    if not service_started:
+        msg = _('No volume service(s) started successfully, terminating.')
+        LOG.error(msg)
+        sys.exit(1)
+
     launcher.wait()