Follow up patch https://review.openstack.org/#/c/640990
That enables py3 execution of Storlet application. This patch addresses Takashi's comment on there, plus missing protocol issue between gateway and daemon_factory. Change-Id: Ia4170fdb46e6ceae6de8a1eb03d7da6a922612b7
This commit is contained in:
parent
1a7b0baba6
commit
5b776f8d80
@ -100,14 +100,15 @@ class StorletDaemonFactory(SBusServer):
|
||||
return pargs, env
|
||||
|
||||
def get_python_args(self, daemon_language, storlet_path, storlet_name,
|
||||
pool_size, uds_path, log_level, language_version):
|
||||
language_version = language_version or 2
|
||||
if int(float(language_version)) == 3:
|
||||
language_version = DEFAULT_PY3
|
||||
pool_size, uds_path, log_level,
|
||||
daemon_language_version):
|
||||
daemon_language_version = daemon_language_version or 2
|
||||
if int(float(daemon_language_version)) == 3:
|
||||
daemon_language_version = DEFAULT_PY3
|
||||
else:
|
||||
language_version = DEFAULT_PY2
|
||||
daemon_language_version = DEFAULT_PY2
|
||||
|
||||
python_interpreter = '/usr/bin/python%s' % language_version
|
||||
python_interpreter = '/usr/bin/python%s' % daemon_language_version
|
||||
str_daemon_main_file = '/usr/local/libexec/storlets/storlets-daemon'
|
||||
pargs = [python_interpreter, str_daemon_main_file, storlet_name,
|
||||
uds_path, log_level, str(pool_size), self.container_id]
|
||||
@ -207,7 +208,7 @@ class StorletDaemonFactory(SBusServer):
|
||||
|
||||
def process_start_daemon(self, daemon_language, storlet_path, storlet_name,
|
||||
pool_size, uds_path, log_level,
|
||||
language_version=None):
|
||||
daemon_language_version=None):
|
||||
"""
|
||||
Start storlet daemon process
|
||||
|
||||
@ -219,7 +220,7 @@ class StorletDaemonFactory(SBusServer):
|
||||
pool provides
|
||||
:param uds_path: Path to pipe daemon is going to listen to
|
||||
:param log_level: Logger verbosity level
|
||||
:param language_version: daemon language version (e.g. py2, py3)
|
||||
:param daemon_language_version: daemon language version (e.g. py2, py3)
|
||||
only python lang supports this option
|
||||
|
||||
:returns: True if it starts a new subprocess
|
||||
@ -232,7 +233,7 @@ class StorletDaemonFactory(SBusServer):
|
||||
elif daemon_language.lower() == 'python':
|
||||
pargs, env = self.get_python_args(
|
||||
daemon_language, storlet_path, storlet_name,
|
||||
pool_size, uds_path, log_level, language_version)
|
||||
pool_size, uds_path, log_level, daemon_language_version)
|
||||
else:
|
||||
raise SDaemonError(
|
||||
'Got unsupported daemon language: %s' % daemon_language)
|
||||
@ -450,7 +451,8 @@ class StorletDaemonFactory(SBusServer):
|
||||
params['daemon_language'], params['storlet_path'],
|
||||
storlet_name, params['pool_size'],
|
||||
params['uds_path'], params['log_level'],
|
||||
language_version=params.get("language_version")):
|
||||
daemon_language_version=params.get(
|
||||
'daemon_language_version')):
|
||||
msg = 'OK'
|
||||
else:
|
||||
msg = '{0} is already running'.format(storlet_name)
|
||||
|
@ -370,7 +370,8 @@ class RunTimeSandbox(object):
|
||||
self._restart(docker_image_name)
|
||||
self.wait()
|
||||
|
||||
def start_storlet_daemon(self, spath, storlet_id, language):
|
||||
def start_storlet_daemon(
|
||||
self, spath, storlet_id, language, language_version=None):
|
||||
"""
|
||||
Start SDaemon process in the scope's sandbox
|
||||
|
||||
@ -382,6 +383,9 @@ class RunTimeSandbox(object):
|
||||
'log_level': self.storlet_daemon_debug_level,
|
||||
'pool_size': self.storlet_daemon_thread_pool_size}
|
||||
|
||||
if language_version:
|
||||
prms.update({'daemon_language_version': language_version})
|
||||
|
||||
with _open_pipe() as (read_fd, write_fd):
|
||||
dtg = SBusServiceDatagram(
|
||||
sbus_cmd.SBUS_CMD_START_DAEMON,
|
||||
@ -511,9 +515,9 @@ class RunTimeSandbox(object):
|
||||
classpath = self._get_storlet_classpath(
|
||||
sreq.storlet_main, sreq.storlet_id, sreq.dependencies)
|
||||
|
||||
daemon_status = \
|
||||
self.start_storlet_daemon(classpath, sreq.storlet_main,
|
||||
sreq.storlet_language)
|
||||
daemon_status = self.start_storlet_daemon(
|
||||
classpath, sreq.storlet_main, sreq.storlet_language,
|
||||
sreq.options.get("storlet_language_version"))
|
||||
|
||||
if daemon_status != 1:
|
||||
self.logger.error('Daemon start Failed, returned code is %d' %
|
||||
|
@ -272,7 +272,7 @@ class StorletProxyHandler(StorletBaseHandler):
|
||||
Add to request the storlet parameters to be used in case the request
|
||||
is forwarded to the data node (GET case)
|
||||
|
||||
:param params: paramegers to be augmented to request
|
||||
:param params: parameters to be augmented to request
|
||||
"""
|
||||
for key, val in params.items():
|
||||
self.request.headers['X-Storlet-' + key] = val
|
||||
|
Loading…
Reference in New Issue
Block a user