Create default archive policies out of the box
This creates default archive policies configuration out of the box when the database is empty. Change-Id: I1c20bc618b9eed4e8a5c8554d5484325a7aac01e Closes-bug: #1538872
This commit is contained in:
parent
c9116028af
commit
b477e4e114
|
@ -398,12 +398,6 @@ function start_gnocchi {
|
||||||
export GNOCCHI_ENDPOINT="$(gnocchi_service_url)"
|
export GNOCCHI_ENDPOINT="$(gnocchi_service_url)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gnocchi archive-policy create -d granularity:5m,points:12 -d granularity:1h,points:24 -d granularity:1d,points:30 low
|
|
||||||
gnocchi archive-policy create -d granularity:60s,points:60 -d granularity:1h,points:168 -d granularity:1d,points:365 medium
|
|
||||||
gnocchi archive-policy create -d granularity:1s,points:86400 -d granularity:1m,points:43200 -d granularity:1h,points:8760 high
|
|
||||||
|
|
||||||
gnocchi archive-policy-rule create -a low -m "*" default
|
|
||||||
|
|
||||||
# run metricd last so we are properly waiting for swift and friends
|
# run metricd last so we are properly waiting for swift and friends
|
||||||
run_process gnocchi-metricd "$GNOCCHI_BIN_DIR/gnocchi-metricd -d -v --config-file $GNOCCHI_CONF"
|
run_process gnocchi-metricd "$GNOCCHI_BIN_DIR/gnocchi-metricd -d -v --config-file $GNOCCHI_CONF"
|
||||||
run_process gnocchi-statsd "$GNOCCHI_BIN_DIR/gnocchi-statsd -d -v --config-file $GNOCCHI_CONF"
|
run_process gnocchi-statsd "$GNOCCHI_BIN_DIR/gnocchi-statsd -d -v --config-file $GNOCCHI_CONF"
|
||||||
|
|
|
@ -207,3 +207,37 @@ class ArchivePolicyItem(dict):
|
||||||
datetime.timedelta(seconds=self.granularity)),
|
datetime.timedelta(seconds=self.granularity)),
|
||||||
'points': self.points,
|
'points': self.points,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DEFAULT_ARCHIVE_POLICIES = {
|
||||||
|
'low': ArchivePolicy(
|
||||||
|
"low", 0, [
|
||||||
|
# 5 minutes resolution for an hour
|
||||||
|
ArchivePolicyItem(granularity=300, points=12),
|
||||||
|
# 1 hour resolution for a day
|
||||||
|
ArchivePolicyItem(granularity=3600, points=24),
|
||||||
|
# 1 day resolution for a month
|
||||||
|
ArchivePolicyItem(granularity=3600 * 24, points=30),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
'medium': ArchivePolicy(
|
||||||
|
"medium", 0, [
|
||||||
|
# 1 minute resolution for an hour
|
||||||
|
ArchivePolicyItem(granularity=60, points=60),
|
||||||
|
# 1 hour resolution for a week
|
||||||
|
ArchivePolicyItem(granularity=3600, points=7 * 24),
|
||||||
|
# 1 day resolution for a year
|
||||||
|
ArchivePolicyItem(granularity=3600 * 24, points=365),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
'high': ArchivePolicy(
|
||||||
|
"high", 0, [
|
||||||
|
# 1 second resolution for a day
|
||||||
|
ArchivePolicyItem(granularity=1, points=3600 * 24),
|
||||||
|
# 1 minute resolution for a month
|
||||||
|
ArchivePolicyItem(granularity=60, points=60 * 24 * 30),
|
||||||
|
# 1 hour resolution for a year
|
||||||
|
ArchivePolicyItem(granularity=3600, points=365 * 24),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
|
@ -22,7 +22,9 @@ import time
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import retrying
|
import retrying
|
||||||
|
import six
|
||||||
|
|
||||||
|
from gnocchi import archive_policy
|
||||||
from gnocchi import indexer
|
from gnocchi import indexer
|
||||||
from gnocchi.rest import app
|
from gnocchi.rest import app
|
||||||
from gnocchi import service
|
from gnocchi import service
|
||||||
|
@ -39,12 +41,14 @@ def upgrade():
|
||||||
cfg.BoolOpt("skip-index", default=False,
|
cfg.BoolOpt("skip-index", default=False,
|
||||||
help="Skip index upgrade."),
|
help="Skip index upgrade."),
|
||||||
cfg.BoolOpt("skip-storage", default=False,
|
cfg.BoolOpt("skip-storage", default=False,
|
||||||
help="Skip storage upgrade.")
|
help="Skip storage upgrade."),
|
||||||
|
cfg.BoolOpt("skip-archive-policies-creation", default=False,
|
||||||
|
help="Skip default archive policies creation.")
|
||||||
])
|
])
|
||||||
conf = service.prepare_service(conf=conf)
|
conf = service.prepare_service(conf=conf)
|
||||||
|
index = indexer.get_driver(conf)
|
||||||
|
index.connect()
|
||||||
if not conf.skip_index:
|
if not conf.skip_index:
|
||||||
index = indexer.get_driver(conf)
|
|
||||||
index.connect()
|
|
||||||
LOG.info("Upgrading indexer %s" % index)
|
LOG.info("Upgrading indexer %s" % index)
|
||||||
index.upgrade()
|
index.upgrade()
|
||||||
if not conf.skip_storage:
|
if not conf.skip_storage:
|
||||||
|
@ -52,6 +56,13 @@ def upgrade():
|
||||||
LOG.info("Upgrading storage %s" % s)
|
LOG.info("Upgrading storage %s" % s)
|
||||||
s.upgrade(index)
|
s.upgrade(index)
|
||||||
|
|
||||||
|
if (not conf.skip_archive_policies_creation
|
||||||
|
and not index.list_archive_policies()
|
||||||
|
and not index.list_archive_policy_rules()):
|
||||||
|
for name, ap in six.iteritems(archive_policy.DEFAULT_ARCHIVE_POLICIES):
|
||||||
|
index.create_archive_policy(ap)
|
||||||
|
index.create_archive_policy_rule("default", "*", "low")
|
||||||
|
|
||||||
|
|
||||||
def api():
|
def api():
|
||||||
app.build_server()
|
app.build_server()
|
||||||
|
|
|
@ -293,51 +293,6 @@ class FakeSwiftClient(object):
|
||||||
class TestCase(base.BaseTestCase):
|
class TestCase(base.BaseTestCase):
|
||||||
|
|
||||||
ARCHIVE_POLICIES = {
|
ARCHIVE_POLICIES = {
|
||||||
'low': archive_policy.ArchivePolicy(
|
|
||||||
"low",
|
|
||||||
0,
|
|
||||||
[
|
|
||||||
# 5 minutes resolution for an hour
|
|
||||||
archive_policy.ArchivePolicyItem(
|
|
||||||
granularity=300, points=12),
|
|
||||||
# 1 hour resolution for a day
|
|
||||||
archive_policy.ArchivePolicyItem(
|
|
||||||
granularity=3600, points=24),
|
|
||||||
# 1 day resolution for a month
|
|
||||||
archive_policy.ArchivePolicyItem(
|
|
||||||
granularity=3600 * 24, points=30),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
'medium': archive_policy.ArchivePolicy(
|
|
||||||
"medium",
|
|
||||||
0,
|
|
||||||
[
|
|
||||||
# 1 minute resolution for an hour
|
|
||||||
archive_policy.ArchivePolicyItem(
|
|
||||||
granularity=60, points=60),
|
|
||||||
# 1 hour resolution for a week
|
|
||||||
archive_policy.ArchivePolicyItem(
|
|
||||||
granularity=3600, points=7 * 24),
|
|
||||||
# 1 day resolution for a year
|
|
||||||
archive_policy.ArchivePolicyItem(
|
|
||||||
granularity=3600 * 24, points=365),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
'high': archive_policy.ArchivePolicy(
|
|
||||||
"high",
|
|
||||||
0,
|
|
||||||
[
|
|
||||||
# 1 second resolution for a day
|
|
||||||
archive_policy.ArchivePolicyItem(
|
|
||||||
granularity=1, points=3600 * 24),
|
|
||||||
# 1 minute resolution for a month
|
|
||||||
archive_policy.ArchivePolicyItem(
|
|
||||||
granularity=60, points=60 * 24 * 30),
|
|
||||||
# 1 hour resolution for a year
|
|
||||||
archive_policy.ArchivePolicyItem(
|
|
||||||
granularity=3600, points=365 * 24),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
'no_granularity_match': archive_policy.ArchivePolicy(
|
'no_granularity_match': archive_policy.ArchivePolicy(
|
||||||
"no_granularity_match",
|
"no_granularity_match",
|
||||||
0,
|
0,
|
||||||
|
@ -392,10 +347,11 @@ class TestCase(base.BaseTestCase):
|
||||||
|
|
||||||
self.coord.stop()
|
self.coord.stop()
|
||||||
|
|
||||||
self.archive_policies = self.ARCHIVE_POLICIES
|
self.archive_policies = self.ARCHIVE_POLICIES.copy()
|
||||||
|
self.archive_policies.update(archive_policy.DEFAULT_ARCHIVE_POLICIES)
|
||||||
# Used in gnocchi.gendoc
|
# Used in gnocchi.gendoc
|
||||||
if not getattr(self, "skip_archive_policies_creation", False):
|
if not getattr(self, "skip_archive_policies_creation", False):
|
||||||
for name, ap in six.iteritems(self.ARCHIVE_POLICIES):
|
for name, ap in six.iteritems(self.archive_policies):
|
||||||
# Create basic archive policies
|
# Create basic archive policies
|
||||||
try:
|
try:
|
||||||
self.index.create_archive_policy(ap)
|
self.index.create_archive_policy(ap)
|
||||||
|
|
Loading…
Reference in New Issue