Limit workers to 0 or 1 when using db.simple.api
When using more than one worker, only one of them will return data, thus leading users to not have access to every single piece of data at once. Change-Id: I0e7e0f0ff7821465a74eb284e8401ddd7238f6df Partial-Bug: #1619508 Co-Authored-By: Cyril Roelandt <cyril@redhat.com> Co-Authored-By: Hemanth Makkapati <hemanth.makkapati@rackspace.com>
This commit is contained in:
parent
00828ec4b5
commit
0cea875293
|
@ -188,7 +188,9 @@ Number of Glance API or Registry worker processes to start. Each worker
|
|||
process will listen on the same port. Increasing this value may increase
|
||||
performance (especially if using SSL with compression enabled). Typically
|
||||
it is recommended to have one worker process per CPU. The value `0`
|
||||
will prevent any new processes from being created.
|
||||
will prevent any new worker processes from being created. When ``data_api``
|
||||
is set to ``glance.db.simple.api``, ``workers`` MUST be set to either ``0`` or
|
||||
``1``.
|
||||
|
||||
Optional. Default: The number of CPUs available will be used by default.
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import copy
|
|||
import functools
|
||||
import uuid
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
|
@ -27,7 +28,7 @@ from glance.common import utils
|
|||
from glance.db import utils as db_utils
|
||||
from glance.i18n import _, _LI, _LW
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
DATA = {
|
||||
|
@ -70,6 +71,15 @@ def log_call(func):
|
|||
return wrapped
|
||||
|
||||
|
||||
def configure():
|
||||
if CONF.workers not in [0, 1]:
|
||||
msg = _('CONF.workers should be set to 0 or 1 when using the '
|
||||
'db.simple.api backend. Fore more info, see '
|
||||
'https://bugs.launchpad.net/glance/+bug/1619508')
|
||||
LOG.critical(msg)
|
||||
raise SystemExit(msg)
|
||||
|
||||
|
||||
def reset():
|
||||
global DATA
|
||||
DATA = {
|
||||
|
|
|
@ -20,9 +20,10 @@ import glance.tests.functional.db as db_tests
|
|||
from glance.tests.functional.db import base
|
||||
|
||||
|
||||
def get_db(config):
|
||||
def get_db(config, workers=1):
|
||||
CONF.set_override('data_api', 'glance.db.simple.api',
|
||||
enforce_type=True)
|
||||
CONF.set_override('workers', workers, enforce_type=True)
|
||||
db_api = glance.db.get_api()
|
||||
return db_api
|
||||
|
||||
|
@ -77,3 +78,15 @@ class TestSimpleTask(base.TaskTests,
|
|||
db_tests.load(get_db, reset_db)
|
||||
super(TestSimpleTask, self).setUp()
|
||||
self.addCleanup(db_tests.reset)
|
||||
|
||||
|
||||
class TestTooManyWorkers(base.TaskTests):
|
||||
|
||||
def setUp(self):
|
||||
def get_db_too_many_workers(config):
|
||||
self.assertRaises(SystemExit, get_db, config, 2)
|
||||
return get_db(config)
|
||||
|
||||
db_tests.load(get_db_too_many_workers, reset_db)
|
||||
super(TestTooManyWorkers, self).setUp()
|
||||
self.addCleanup(db_tests.reset)
|
||||
|
|
Loading…
Reference in New Issue