]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fixes cinder-volume service startup on Windows
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Fri, 7 Mar 2014 15:09:33 +0000 (17:09 +0200)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Tue, 11 Mar 2014 17:55:13 +0000 (19:55 +0200)
The Windows service fails due to missing non-blocking IO features
in eventlet. This fix adds a conditional path on Windows to execute
the service accordingly.

This bug had already been fixed by this this commit:
https://review.openstack.org/#/c/44744/ but it had been reverted
here, causing the Windows service to fail again
https://review.openstack.org/67031

Fixes bug: #1219896

Change-Id: I46c6b332e614b6a84ec8372dbec3ee9fb09336de

bin/cinder-volume
cinder/service.py [changed mode: 0644->0755]
cinder/tests/test_service.py [changed mode: 0644->0755]

index e9af49cf34b0ef46e41e5f30060a5d947ba5c143..9a0999439ed001b6cfcf9a5f32fd5b3636180c7b 100755 (executable)
@@ -59,10 +59,7 @@ if __name__ == '__main__':
          version=version.version_string())
     logging.setup("cinder")
     utils.monkey_patch()
-    # Note(zhiteng): Since Windows (os='nt') has already ignored monkey
-    # patching 'os' module, there is no need to treat it differently
-    # when creating launcher.
-    launcher = service.process_launcher()
+    launcher = service.get_launcher()
     if CONF.enabled_backends:
         for backend in CONF.enabled_backends:
             host = "%s@%s" % (CONF.host, backend)
old mode 100644 (file)
new mode 100755 (executable)
index 1091729..763ad47
@@ -389,3 +389,20 @@ def wait():
     except KeyboardInterrupt:
         _launcher.stop()
     rpc.cleanup()
+
+
+class Launcher(object):
+    def __init__(self):
+        self.launch_service = serve
+        self.wait = wait
+
+
+def get_launcher():
+    # Note(lpetrut): ProcessLauncher uses green pipes which fail on Windows
+    # due to missing support of non-blocking I/O pipes. For this reason, the
+    # service must be spawned differently on Windows, using the ServiceLauncher
+    # class instead.
+    if os.name == 'nt':
+        return Launcher()
+    else:
+        return process_launcher()
old mode 100644 (file)
new mode 100755 (executable)
index 0f34a52..9ed0c16
@@ -20,6 +20,7 @@ Unit Tests for remote procedure calls using queue
 """
 
 
+import mock
 import mox
 from oslo.config import cfg
 
@@ -215,3 +216,27 @@ class TestWSGIService(test.TestCase):
         test_service.start()
         self.assertNotEqual(0, test_service.port)
         test_service.stop()
+
+
+class OSCompatibilityTestCase(test.TestCase):
+    def _test_service_launcher(self, fake_os):
+        # Note(lpetrut): The cinder-volume service needs to be spawned
+        # differently on Windows due to an eventlet bug. For this reason,
+        # we must check the process launcher used.
+        fake_process_launcher = mock.MagicMock()
+        with mock.patch('os.name', fake_os):
+            with mock.patch('cinder.service.process_launcher',
+                            fake_process_launcher):
+                launcher = service.get_launcher()
+                if fake_os == 'nt':
+                    self.assertEqual(type(launcher),
+                                     service.Launcher)
+                else:
+                    self.assertEqual(launcher,
+                                     fake_process_launcher())
+
+    def test_process_launcher_on_windows(self):
+        self._test_service_launcher('nt')
+
+    def test_process_launcher_on_linux(self):
+        self._test_service_launcher('posix')