don't pass ceilometer options to oslo.db engine facade

oslo.db EngineFacade class only support options defined by oslo.db,
but we're passing options defined by ceilometer, so oslo.db complains
with a warning message:

NotSupportedWarning: Configuration option(s) ['alarm_connection', \
'alarm_history_time_to_live', 'db2nosql_resource_id_maxlen', \
'event_connection', 'event_time_to_live', 'metering_connection', \
'metering_time_to_live'] not supported exception.NotSupportedWarning

This patch makes sure only options defined by oslo.db will be sent
to EngineFacade

Change-Id: I2a39737a5f7824918c28ff2180f2ea95e7e82537
Closes-Bug: #1516515
This commit is contained in:
ZhiQiang Fan 2015-11-17 00:34:16 +08:00
parent 400ea6ecb1
commit 43c65a3b65
3 changed files with 20 additions and 0 deletions

View File

@ -27,6 +27,7 @@ import sqlalchemy as sa
from ceilometer.event.storage import base
from ceilometer.event.storage import models as api_models
from ceilometer.i18n import _LE, _LI
from ceilometer import storage
from ceilometer.storage.sqlalchemy import models
from ceilometer import utils
@ -130,6 +131,9 @@ class Connection(base.Connection):
# in storage.__init__.get_connection_from_config function
options = dict(cfg.CONF.database.items())
options['max_retries'] = 0
# oslo.db doesn't support options defined by Ceilometer
for opt in storage.OPTS:
options.pop(opt.name, None)
self._engine_facade = db_session.EngineFacade(url, **options)
def upgrade(self):

View File

@ -223,6 +223,9 @@ class Connection(base.Connection):
# in storage.__init__.get_connection_from_config function
options = dict(cfg.CONF.database.items())
options['max_retries'] = 0
# oslo.db doesn't support options defined by Ceilometer
for opt in storage.OPTS:
options.pop(opt.name, None)
self._engine_facade = db_session.EngineFacade(url, **options)
def upgrade(self):

View File

@ -19,8 +19,10 @@
"""
import datetime
import warnings
import mock
from oslo_db import exception
from oslo_utils import timeutils
from six.moves import reprlib
@ -43,6 +45,17 @@ class CeilometerBaseTest(tests_db.TestBase):
self.assertEqual('value', base['key'])
@tests_db.run_with('sqlite')
class EngineFacadeTest(tests_db.TestBase):
@mock.patch.object(warnings, 'warn')
def test_no_not_supported_warning(self, mocked):
impl_sqlalchemy.Connection('sqlite://')
impl_sqla_event.Connection('sqlite://')
self.assertNotIn(mock.call(mock.ANY, exception.NotSupportedWarning),
mocked.call_args_list)
@tests_db.run_with('sqlite', 'mysql', 'pgsql')
class EventTypeTest(tests_db.TestBase):
# EventType is a construct specific to sqlalchemy