Change default value for [wsgi]/python_interpreter
The default value is being set too early. We don't want to use the value of sys.executable at the time the config is generated, because that's unlikely to map to an existing interpreter in an actual deployment. Change-Id: Ic40f582f83e04c6915a3fcb231d6d95ca071c100 Closes-bug: #1962581
This commit is contained in:
parent
f5776e6c1c
commit
daa602baa9
@ -15,6 +15,7 @@
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
from oslo_concurrency import processutils as putils
|
||||
from oslo_config import cfg
|
||||
@ -69,7 +70,7 @@ class _ConvertImage(task.Task):
|
||||
self.action_wrapper = action_wrapper
|
||||
self.image_id = action_wrapper.image_id
|
||||
self.dest_path = ""
|
||||
self.python = CONF.wsgi.python_interpreter
|
||||
self.python = CONF.wsgi.python_interpreter or sys.executable
|
||||
super(_ConvertImage, self).__init__(
|
||||
name='%s-Convert_Image-%s' % (task_type, task_id))
|
||||
|
||||
|
@ -19,7 +19,6 @@ Routines for configuring Glance
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_middleware import cors
|
||||
@ -641,13 +640,13 @@ may overwhelm other system resources such as disk or outbound network
|
||||
bandwidth. If this is too small, image import requests will have to wait
|
||||
until a thread becomes available to begin processing.""")),
|
||||
cfg.StrOpt('python_interpreter',
|
||||
default=sys.executable,
|
||||
default=None,
|
||||
help=_("""
|
||||
Path to the python interpreter to use when spawning external
|
||||
processes. By default this is sys.executable, which should be the
|
||||
same interpreter running Glance itself. However, in some situations
|
||||
(i.e. uwsgi) this may not actually point to a python interpreter
|
||||
itself.""")),
|
||||
processes. If left unspecified, this will be sys.executable, which should
|
||||
be the same interpreter running Glance itself. However, in some situations
|
||||
(for example, uwsgi) sys.executable may not actually point to a python
|
||||
interpreter and an alternative value must be set.""")),
|
||||
]
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from unittest import mock
|
||||
|
||||
import glance_store
|
||||
@ -264,3 +265,22 @@ class TestConvertImageTask(test_utils.BaseTestCase):
|
||||
os_exists_mock.return_value = True
|
||||
image_convert.revert(result=mock.MagicMock())
|
||||
self.assertEqual(1, mock_os_remove.call_count)
|
||||
|
||||
def test_image_convert_interpreter_resolution(self):
|
||||
# By default, wsgi.python_interpreter is None, which we should
|
||||
# translate to sys.executable at runtime.
|
||||
convert = image_conversion._ConvertImage(self.context,
|
||||
self.task.task_id,
|
||||
self.task_type,
|
||||
self.wrapper)
|
||||
self.assertEqual(sys.executable, convert.python)
|
||||
|
||||
# If overridden, we should take the interpreter from config.
|
||||
fake_interpreter = '/usr/bin/python2.7'
|
||||
self.config(python_interpreter=fake_interpreter,
|
||||
group='wsgi')
|
||||
convert = image_conversion._ConvertImage(self.context,
|
||||
self.task.task_id,
|
||||
self.task_type,
|
||||
self.wrapper)
|
||||
self.assertEqual(fake_interpreter, convert.python)
|
||||
|
Loading…
Reference in New Issue
Block a user