storage: autoconfigure coordination_url
This makes the storage leverage the indexer URL by default, avoiding user mistake of not configuring it properly and making it work by default for multi node environment. Wouhouh! Change-Id: I8ef35d9e118e2d2a6a87ce6db15a2212df7f355d
This commit is contained in:
parent
f4e6f52832
commit
0fd52b5820
|
@ -226,11 +226,9 @@ function configure_gnocchi {
|
||||||
# Install the configuration files
|
# Install the configuration files
|
||||||
cp $GNOCCHI_DIR/etc/gnocchi/* $GNOCCHI_CONF_DIR
|
cp $GNOCCHI_DIR/etc/gnocchi/* $GNOCCHI_CONF_DIR
|
||||||
|
|
||||||
|
|
||||||
|
if [ -n "$GNOCCHI_COORDINATOR_URL" ]; then
|
||||||
iniset $GNOCCHI_CONF storage coordination_url "$GNOCCHI_COORDINATOR_URL"
|
iniset $GNOCCHI_CONF storage coordination_url "$GNOCCHI_COORDINATOR_URL"
|
||||||
if [ "${GNOCCHI_COORDINATOR_URL:0:7}" == "file://" ]; then
|
|
||||||
gnocchi_locks_dir=${GNOCCHI_COORDINATOR_URL:7}
|
|
||||||
[ ! -d $gnocchi_locks_dir ] && sudo mkdir -m 755 -p ${gnocchi_locks_dir}
|
|
||||||
sudo chown $STACK_USER $gnocchi_locks_dir
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Configure auth token middleware
|
# Configure auth token middleware
|
||||||
|
|
|
@ -11,7 +11,6 @@ GNOCCHI_LOG_DIR=/var/log/gnocchi
|
||||||
GNOCCHI_AUTH_CACHE_DIR=${GNOCCHI_AUTH_CACHE_DIR:-/var/cache/gnocchi}
|
GNOCCHI_AUTH_CACHE_DIR=${GNOCCHI_AUTH_CACHE_DIR:-/var/cache/gnocchi}
|
||||||
GNOCCHI_WSGI_DIR=${GNOCCHI_WSGI_DIR:-/var/www/gnocchi}
|
GNOCCHI_WSGI_DIR=${GNOCCHI_WSGI_DIR:-/var/www/gnocchi}
|
||||||
GNOCCHI_DATA_DIR=${GNOCCHI_DATA_DIR:-${DATA_DIR}/gnocchi}
|
GNOCCHI_DATA_DIR=${GNOCCHI_DATA_DIR:-${DATA_DIR}/gnocchi}
|
||||||
GNOCCHI_COORDINATOR_URL=${GNOCCHI_COORDINATOR_URL:-file://${GNOCCHI_DATA_DIR}/locks}
|
|
||||||
|
|
||||||
# Toggle for deploying Gnocchi under HTTPD + mod_wsgi
|
# Toggle for deploying Gnocchi under HTTPD + mod_wsgi
|
||||||
GNOCCHI_USE_MOD_WSGI=${GNOCCHI_USE_MOD_WSGI:-${ENABLE_HTTPD_MOD_WSGI_SERVICES}}
|
GNOCCHI_USE_MOD_WSGI=${GNOCCHI_USE_MOD_WSGI:-${ENABLE_HTTPD_MOD_WSGI_SERVICES}}
|
||||||
|
|
|
@ -103,12 +103,13 @@ To ensure consistency across all *gnocchi-api* and *gnocchi-metricd* workers,
|
||||||
these drivers need a distributed locking mechanism. This is provided by the
|
these drivers need a distributed locking mechanism. This is provided by the
|
||||||
'coordinator' of the `tooz`_ library.
|
'coordinator' of the `tooz`_ library.
|
||||||
|
|
||||||
By default, the configured backend for `tooz`_ is `file`, this allows locking
|
By default, the configured backend for `tooz`_ is the same as the indexer
|
||||||
across workers on the same node.
|
(*PostgreSQL* or *MySQL*). This allows locking across workers from different
|
||||||
|
nodes.
|
||||||
|
|
||||||
In a multi-nodes deployment, the coordinator needs to be changed via
|
For a more robust multi-nodes deployment, the coordinator may be changed via
|
||||||
the storage/coordination_url configuration options to one of the other
|
the `storage.coordination_url` configuration option to one of the other `tooz
|
||||||
`tooz backends`_.
|
backends`_.
|
||||||
|
|
||||||
For example to use Redis backend::
|
For example to use Redis backend::
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Copyright (c) 2013 Mirantis Inc.
|
# Copyright (c) 2016 Red Hat, Inc.
|
||||||
# Copyright (c) 2015 eNovance
|
# Copyright (c) 2015 eNovance
|
||||||
|
# Copyright (c) 2013 Mirantis Inc.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -21,6 +22,7 @@ from oslo_config import cfg
|
||||||
from oslo_db import options as db_options
|
from oslo_db import options as db_options
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_policy import opts as policy_opts
|
from oslo_policy import opts as policy_opts
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from gnocchi import archive_policy
|
from gnocchi import archive_policy
|
||||||
from gnocchi import opts
|
from gnocchi import opts
|
||||||
|
@ -57,6 +59,19 @@ def prepare_service(args=None, conf=None,
|
||||||
|
|
||||||
conf(args, project='gnocchi', validate_default_values=True,
|
conf(args, project='gnocchi', validate_default_values=True,
|
||||||
default_config_files=default_config_files)
|
default_config_files=default_config_files)
|
||||||
|
|
||||||
|
# If no coordination URL is provided, default to using the indexer as
|
||||||
|
# coordinator
|
||||||
|
if conf.storage.coordination_url is None:
|
||||||
|
parsed = urlparse.urlparse(conf.indexer.url)
|
||||||
|
proto, _, _ = parsed.scheme.partition("+")
|
||||||
|
parsed = list(parsed)
|
||||||
|
# Set proto without the + part
|
||||||
|
parsed[0] = proto
|
||||||
|
conf.set_default("coordination_url",
|
||||||
|
urlparse.urlunparse(parsed),
|
||||||
|
"storage")
|
||||||
|
|
||||||
log.setup(conf, 'gnocchi')
|
log.setup(conf, 'gnocchi')
|
||||||
conf.log_opt_values(LOG, logging.DEBUG)
|
conf.log_opt_values(LOG, logging.DEBUG)
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,7 @@ OPTS = [
|
||||||
'pre-aggregation needs.'),
|
'pre-aggregation needs.'),
|
||||||
cfg.StrOpt('coordination_url',
|
cfg.StrOpt('coordination_url',
|
||||||
secret=True,
|
secret=True,
|
||||||
help='Coordination driver URL',
|
help='Coordination driver URL'),
|
||||||
default="file:///var/lib/gnocchi/locks"),
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -347,17 +347,13 @@ class TestCase(base.BaseTestCase):
|
||||||
self.index = indexer.get_driver(self.conf)
|
self.index = indexer.get_driver(self.conf)
|
||||||
self.index.connect()
|
self.index.connect()
|
||||||
|
|
||||||
self.conf.set_override('coordination_url',
|
|
||||||
os.getenv("GNOCCHI_COORDINATION_URL", "ipc://"),
|
|
||||||
'storage')
|
|
||||||
|
|
||||||
# NOTE(jd) So, some driver, at least SQLAlchemy, can't create all
|
# NOTE(jd) So, some driver, at least SQLAlchemy, can't create all
|
||||||
# their tables in a single transaction even with the
|
# their tables in a single transaction even with the
|
||||||
# checkfirst=True, so what we do here is we force the upgrade code
|
# checkfirst=True, so what we do here is we force the upgrade code
|
||||||
# path to be sequential to avoid race conditions as the tests run
|
# path to be sequential to avoid race conditions as the tests run
|
||||||
# in parallel.
|
# in parallel.
|
||||||
self.coord = coordination.get_coordinator(
|
self.coord = coordination.get_coordinator(
|
||||||
os.getenv("GNOCCHI_COORDINATION_URL", "ipc://"),
|
self.conf.storage.coordination_url,
|
||||||
str(uuid.uuid4()).encode('ascii'))
|
str(uuid.uuid4()).encode('ascii'))
|
||||||
|
|
||||||
self.coord.start()
|
self.coord.start()
|
||||||
|
|
|
@ -95,10 +95,6 @@ class ConfigFixture(fixture.GabbiFixture):
|
||||||
# and thus should override conf settings.
|
# and thus should override conf settings.
|
||||||
if 'DEVSTACK_GATE_TEMPEST' not in os.environ:
|
if 'DEVSTACK_GATE_TEMPEST' not in os.environ:
|
||||||
conf.set_override('driver', 'file', 'storage')
|
conf.set_override('driver', 'file', 'storage')
|
||||||
conf.set_override(
|
|
||||||
'coordination_url',
|
|
||||||
os.getenv("GNOCCHI_COORDINATION_URL", "ipc://"),
|
|
||||||
'storage')
|
|
||||||
conf.set_override('policy_file',
|
conf.set_override('policy_file',
|
||||||
os.path.abspath('etc/gnocchi/policy.json'),
|
os.path.abspath('etc/gnocchi/policy.json'),
|
||||||
group="oslo_policy")
|
group="oslo_policy")
|
||||||
|
|
|
@ -5,7 +5,6 @@ set -x
|
||||||
GNOCCHI_TEST_INDEXER_DRIVER=${GNOCCHI_TEST_INDEXER_DRIVER:-postgresql}
|
GNOCCHI_TEST_INDEXER_DRIVER=${GNOCCHI_TEST_INDEXER_DRIVER:-postgresql}
|
||||||
source $(which overtest) $GNOCCHI_TEST_INDEXER_DRIVER
|
source $(which overtest) $GNOCCHI_TEST_INDEXER_DRIVER
|
||||||
export GNOCCHI_INDEXER_URL=${OVERTEST_URL/#mysql:/mysql+pymysql:}
|
export GNOCCHI_INDEXER_URL=${OVERTEST_URL/#mysql:/mysql+pymysql:}
|
||||||
export GNOCCHI_COORDINATION_URL=${OVERTEST_URL}
|
|
||||||
# Activate overtest for storage
|
# Activate overtest for storage
|
||||||
case $GNOCCHI_TEST_STORAGE_DRIVER in
|
case $GNOCCHI_TEST_STORAGE_DRIVER in
|
||||||
influxdb)
|
influxdb)
|
||||||
|
|
|
@ -39,15 +39,15 @@ swift =
|
||||||
python-swiftclient>=2.5.0
|
python-swiftclient>=2.5.0
|
||||||
msgpack-python
|
msgpack-python
|
||||||
lz4
|
lz4
|
||||||
tooz>=1.22
|
tooz>=1.30
|
||||||
ceph =
|
ceph =
|
||||||
msgpack-python
|
msgpack-python
|
||||||
lz4
|
lz4
|
||||||
tooz>=1.22
|
tooz>=1.30
|
||||||
file =
|
file =
|
||||||
msgpack-python
|
msgpack-python
|
||||||
lz4
|
lz4
|
||||||
tooz>=1.22
|
tooz>=1.30
|
||||||
doc =
|
doc =
|
||||||
oslosphinx>=2.2.0
|
oslosphinx>=2.2.0
|
||||||
sphinx
|
sphinx
|
||||||
|
@ -68,8 +68,7 @@ test =
|
||||||
testtools>=0.9.38
|
testtools>=0.9.38
|
||||||
WebTest>=2.0.16
|
WebTest>=2.0.16
|
||||||
doc8
|
doc8
|
||||||
sysv_ipc
|
tooz>=1.30
|
||||||
tooz>=1.22
|
|
||||||
keystonemiddleware>=4.0.0
|
keystonemiddleware>=4.0.0
|
||||||
|
|
||||||
[global]
|
[global]
|
||||||
|
|
Loading…
Reference in New Issue