Remove sql-expire-samples-only as a CLI option
This option actually changes the behaviour of the driver, so it should not be passed only as a CLI option, but should be set in the configuration file. Change-Id: I3540b2db1c039320e387d7a0484b351b082d00de
This commit is contained in:
parent
fe901c3d31
commit
5c05c047a6
|
@ -75,7 +75,6 @@ def list_opts():
|
|||
ceilometer.pipeline.OPTS,
|
||||
ceilometer.sample.OPTS,
|
||||
ceilometer.service.OPTS,
|
||||
ceilometer.storage.CLI_OPTS,
|
||||
ceilometer.utils.OPTS,)),
|
||||
('api',
|
||||
itertools.chain(ceilometer.api.OPTS,
|
||||
|
|
|
@ -47,20 +47,15 @@ OPTS = [
|
|||
secret=True,
|
||||
help='The connection string used to connect to the event '
|
||||
'database. (if unset, connection is used)'),
|
||||
cfg.BoolOpt('sql-expire-samples-only',
|
||||
default=False,
|
||||
help="Indicates if expirer expires only samples. If set true,"
|
||||
" expired samples will be deleted, but residual"
|
||||
" resource and meter definition data will remain."),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(OPTS, group='database')
|
||||
|
||||
CLI_OPTS = [
|
||||
cfg.BoolOpt('sql-expire-samples-only',
|
||||
default=False,
|
||||
help="Indicates if expirer expires only samples. If set true,"
|
||||
" expired samples will be deleted, but residual"
|
||||
" resource and meter definition data will remain.",
|
||||
),
|
||||
]
|
||||
|
||||
cfg.CONF.register_cli_opts(CLI_OPTS)
|
||||
|
||||
db_options.set_defaults(cfg.CONF)
|
||||
|
||||
|
|
|
@ -384,7 +384,7 @@ class Connection(base.Connection):
|
|||
rows = sample_q.delete()
|
||||
LOG.info(_LI("%d samples removed from database"), rows)
|
||||
|
||||
if not cfg.CONF.sql_expire_samples_only:
|
||||
if not cfg.CONF.database.sql_expire_samples_only:
|
||||
with session.begin():
|
||||
# remove Meter definitions with no matching samples
|
||||
(session.query(models.Meter)
|
||||
|
@ -456,7 +456,7 @@ class Connection(base.Connection):
|
|||
# NOTE: When sql_expire_samples_only is enabled, there will be some
|
||||
# resources without any sample, in such case we should use inner
|
||||
# join on sample table to avoid wrong result.
|
||||
if cfg.CONF.sql_expire_samples_only or has_timestamp:
|
||||
if cfg.CONF.database.sql_expire_samples_only or has_timestamp:
|
||||
res_q = session.query(distinct(models.Resource.resource_id)).join(
|
||||
models.Sample,
|
||||
models.Sample.resource_id == models.Resource.internal_id)
|
||||
|
|
|
@ -605,7 +605,7 @@ class RawSampleTest(DBTestBase):
|
|||
@tests_db.run_with('sqlite', 'mysql', 'pgsql')
|
||||
def test_clear_metering_data_expire_samples_only(self):
|
||||
|
||||
cfg.CONF.set_override('sql_expire_samples_only', True)
|
||||
cfg.CONF.set_override('sql_expire_samples_only', True, 'database')
|
||||
self.mock_utcnow.return_value = datetime.datetime(2012, 7, 2, 10, 45)
|
||||
self.conn.clear_expired_metering_data(4 * 60)
|
||||
f = storage.SampleFilter(meter='instance')
|
||||
|
|
Loading…
Reference in New Issue