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:
Kota Tsuyuzaki 2019-03-08 15:56:41 +09:00
parent 1a7b0baba6
commit 5b776f8d80
3 changed files with 21 additions and 15 deletions

View File

@ -100,14 +100,15 @@ class StorletDaemonFactory(SBusServer):
return pargs, env return pargs, env
def get_python_args(self, daemon_language, storlet_path, storlet_name, def get_python_args(self, daemon_language, storlet_path, storlet_name,
pool_size, uds_path, log_level, language_version): pool_size, uds_path, log_level,
language_version = language_version or 2 daemon_language_version):
if int(float(language_version)) == 3: daemon_language_version = daemon_language_version or 2
language_version = DEFAULT_PY3 if int(float(daemon_language_version)) == 3:
daemon_language_version = DEFAULT_PY3
else: 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' str_daemon_main_file = '/usr/local/libexec/storlets/storlets-daemon'
pargs = [python_interpreter, str_daemon_main_file, storlet_name, pargs = [python_interpreter, str_daemon_main_file, storlet_name,
uds_path, log_level, str(pool_size), self.container_id] 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, def process_start_daemon(self, daemon_language, storlet_path, storlet_name,
pool_size, uds_path, log_level, pool_size, uds_path, log_level,
language_version=None): daemon_language_version=None):
""" """
Start storlet daemon process Start storlet daemon process
@ -219,7 +220,7 @@ class StorletDaemonFactory(SBusServer):
pool provides pool provides
:param uds_path: Path to pipe daemon is going to listen to :param uds_path: Path to pipe daemon is going to listen to
:param log_level: Logger verbosity level :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 only python lang supports this option
:returns: True if it starts a new subprocess :returns: True if it starts a new subprocess
@ -232,7 +233,7 @@ class StorletDaemonFactory(SBusServer):
elif daemon_language.lower() == 'python': elif daemon_language.lower() == 'python':
pargs, env = self.get_python_args( pargs, env = self.get_python_args(
daemon_language, storlet_path, storlet_name, daemon_language, storlet_path, storlet_name,
pool_size, uds_path, log_level, language_version) pool_size, uds_path, log_level, daemon_language_version)
else: else:
raise SDaemonError( raise SDaemonError(
'Got unsupported daemon language: %s' % daemon_language) 'Got unsupported daemon language: %s' % daemon_language)
@ -450,7 +451,8 @@ class StorletDaemonFactory(SBusServer):
params['daemon_language'], params['storlet_path'], params['daemon_language'], params['storlet_path'],
storlet_name, params['pool_size'], storlet_name, params['pool_size'],
params['uds_path'], params['log_level'], params['uds_path'], params['log_level'],
language_version=params.get("language_version")): daemon_language_version=params.get(
'daemon_language_version')):
msg = 'OK' msg = 'OK'
else: else:
msg = '{0} is already running'.format(storlet_name) msg = '{0} is already running'.format(storlet_name)

View File

@ -370,7 +370,8 @@ class RunTimeSandbox(object):
self._restart(docker_image_name) self._restart(docker_image_name)
self.wait() 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 Start SDaemon process in the scope's sandbox
@ -382,6 +383,9 @@ class RunTimeSandbox(object):
'log_level': self.storlet_daemon_debug_level, 'log_level': self.storlet_daemon_debug_level,
'pool_size': self.storlet_daemon_thread_pool_size} '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): with _open_pipe() as (read_fd, write_fd):
dtg = SBusServiceDatagram( dtg = SBusServiceDatagram(
sbus_cmd.SBUS_CMD_START_DAEMON, sbus_cmd.SBUS_CMD_START_DAEMON,
@ -511,9 +515,9 @@ class RunTimeSandbox(object):
classpath = self._get_storlet_classpath( classpath = self._get_storlet_classpath(
sreq.storlet_main, sreq.storlet_id, sreq.dependencies) sreq.storlet_main, sreq.storlet_id, sreq.dependencies)
daemon_status = \ daemon_status = self.start_storlet_daemon(
self.start_storlet_daemon(classpath, sreq.storlet_main, classpath, sreq.storlet_main, sreq.storlet_language,
sreq.storlet_language) sreq.options.get("storlet_language_version"))
if daemon_status != 1: if daemon_status != 1:
self.logger.error('Daemon start Failed, returned code is %d' % self.logger.error('Daemon start Failed, returned code is %d' %

View File

@ -272,7 +272,7 @@ class StorletProxyHandler(StorletBaseHandler):
Add to request the storlet parameters to be used in case the request Add to request the storlet parameters to be used in case the request
is forwarded to the data node (GET case) 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(): for key, val in params.items():
self.request.headers['X-Storlet-' + key] = val self.request.headers['X-Storlet-' + key] = val