Fixes cinder-volume service startup on Windows
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
This commit is contained in:
parent
015555acb7
commit
7171984aab
@ -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)
|
||||
|
17
cinder/service.py
Normal file → Executable file
17
cinder/service.py
Normal file → Executable file
@ -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()
|
||||
|
25
cinder/tests/test_service.py
Normal file → Executable file
25
cinder/tests/test_service.py
Normal file → Executable file
@ -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')
|
||||
|
Loading…
x
Reference in New Issue
Block a user