Merge "Change default value for [wsgi]/python_interpreter"

This commit is contained in:
Zuul 2022-03-02 01:03:52 +00:00 committed by Gerrit Code Review
commit ca6c0681cf
3 changed files with 27 additions and 7 deletions

View File

@ -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))

View File

@ -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.""")),
]

View File

@ -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)