Dump loaded config options during start up
... so that we can review effective config values, which is helpful for debugging. Note that cloudkitty-processor uses the implementation provided by cotyledon. This change also has a side benefit to leverage a few tunables such as graceful_shutdown_timeout from cotyledon as well. Change-Id: I7028f93cf23f99dcf151fd2ffc26862bccffc1a1 Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
committed by
Pierre Riteau
parent
38de7d1b28
commit
caa13fa006
@@ -93,6 +93,7 @@ def load_app():
|
||||
|
||||
def build_wsgi_app(argv=None):
|
||||
service.prepare_service()
|
||||
CONF.log_opt_values(LOG, log.DEBUG)
|
||||
return load_app()
|
||||
|
||||
|
||||
|
||||
@@ -13,11 +13,22 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
import cotyledon
|
||||
from cotyledon import oslo_config_glue
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
|
||||
from cloudkitty import service
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
def main():
|
||||
sm = cotyledon.ServiceManager()
|
||||
service.prepare_service()
|
||||
oslo_config_glue.setup(sm, CONF)
|
||||
|
||||
# NOTE(mc): This import is done here to ensure that the prepare_service()
|
||||
# function is called before any cfg option. By importing the orchestrator
|
||||
@@ -25,7 +36,22 @@ def main():
|
||||
# before the prepare_service(), making cfg.CONF returning default values
|
||||
# systematically.
|
||||
from cloudkitty import orchestrator
|
||||
orchestrator.CloudKittyServiceManager().run()
|
||||
|
||||
if CONF.orchestrator.max_workers:
|
||||
sm.add(
|
||||
orchestrator.CloudKittyProcessor,
|
||||
workers=CONF.orchestrator.max_workers)
|
||||
else:
|
||||
LOG.info("No worker configured for CloudKitty processing.")
|
||||
|
||||
if CONF.orchestrator.max_workers_reprocessing:
|
||||
sm.add(
|
||||
orchestrator.CloudKittyReprocessor,
|
||||
workers=CONF.orchestrator.max_workers_reprocessing)
|
||||
else:
|
||||
LOG.info("No worker configured for CloudKitty reprocessing.")
|
||||
|
||||
sm.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -741,21 +741,3 @@ class CloudKittyReprocessor(CloudKittyProcessor):
|
||||
scope.identifier,
|
||||
scope.start_reprocess_time,
|
||||
scope.end_reprocess_time)
|
||||
|
||||
|
||||
class CloudKittyServiceManager(cotyledon.ServiceManager):
|
||||
|
||||
def __init__(self):
|
||||
super(CloudKittyServiceManager, self).__init__()
|
||||
if CONF.orchestrator.max_workers:
|
||||
self.cloudkitty_processor_service_id = self.add(
|
||||
CloudKittyProcessor, workers=CONF.orchestrator.max_workers)
|
||||
else:
|
||||
LOG.info("No worker configured for CloudKitty processing.")
|
||||
|
||||
if CONF.orchestrator.max_workers_reprocessing:
|
||||
self.cloudkitty_reprocessor_service_id = self.add(
|
||||
CloudKittyReprocessor,
|
||||
workers=CONF.orchestrator.max_workers_reprocessing)
|
||||
else:
|
||||
LOG.info("No worker configured for CloudKitty reprocessing.")
|
||||
|
||||
@@ -170,66 +170,6 @@ class OrchestratorTest(tests.TestCase):
|
||||
self.assertEqual('fake2', worker._processors[2].name)
|
||||
self.assertEqual(1, worker._processors[2].obj.priority)
|
||||
|
||||
@mock.patch("cotyledon.ServiceManager.add")
|
||||
@mock.patch("cotyledon._service_manager.ServiceManager.__init__")
|
||||
def test_cloudkitty_service_manager_only_processing(
|
||||
self, service_manager_init_mock, cotyledon_add_mock):
|
||||
|
||||
OrchestratorTest.execute_cloudkitty_service_manager_test(
|
||||
cotyledon_add_mock=cotyledon_add_mock, max_workers_reprocessing=0,
|
||||
max_workers=1)
|
||||
|
||||
self.assertTrue(service_manager_init_mock.called)
|
||||
|
||||
@mock.patch("cotyledon.ServiceManager.add")
|
||||
@mock.patch("cotyledon._service_manager.ServiceManager.__init__")
|
||||
def test_cloudkitty_service_manager_only_reprocessing(
|
||||
self, service_manager_init_mock, cotyledon_add_mock):
|
||||
OrchestratorTest.execute_cloudkitty_service_manager_test(
|
||||
cotyledon_add_mock=cotyledon_add_mock, max_workers_reprocessing=1,
|
||||
max_workers=0)
|
||||
|
||||
self.assertTrue(service_manager_init_mock.called)
|
||||
|
||||
@mock.patch("cotyledon.ServiceManager.add")
|
||||
@mock.patch("cotyledon._service_manager.ServiceManager.__init__")
|
||||
def test_cloudkitty_service_manager_both_processings(
|
||||
self, service_manager_init_mock, cotyledon_add_mock):
|
||||
OrchestratorTest.execute_cloudkitty_service_manager_test(
|
||||
cotyledon_add_mock=cotyledon_add_mock)
|
||||
|
||||
self.assertTrue(service_manager_init_mock.called)
|
||||
|
||||
@staticmethod
|
||||
def execute_cloudkitty_service_manager_test(cotyledon_add_mock=None,
|
||||
max_workers=1,
|
||||
max_workers_reprocessing=1):
|
||||
|
||||
original_conf = orchestrator.CONF
|
||||
try:
|
||||
orchestrator.CONF = mock.Mock()
|
||||
orchestrator.CONF.orchestrator = mock.Mock()
|
||||
orchestrator.CONF.orchestrator.max_workers = max_workers
|
||||
orchestrator.CONF.orchestrator.max_workers_reprocessing = \
|
||||
max_workers_reprocessing
|
||||
|
||||
orchestrator.CloudKittyServiceManager()
|
||||
|
||||
expected_calls = []
|
||||
if max_workers:
|
||||
expected_calls.append(
|
||||
mock.call(orchestrator.CloudKittyProcessor,
|
||||
workers=max_workers))
|
||||
|
||||
if max_workers_reprocessing:
|
||||
expected_calls.append(
|
||||
mock.call(orchestrator.CloudKittyReprocessor,
|
||||
workers=max_workers_reprocessing))
|
||||
|
||||
cotyledon_add_mock.assert_has_calls(expected_calls)
|
||||
finally:
|
||||
orchestrator.CONF = original_conf
|
||||
|
||||
|
||||
class WorkerTest(tests.TestCase):
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[DEFAULT]
|
||||
output_file = etc/cloudkitty/cloudkitty.conf.sample
|
||||
namespace = cloudkitty.common.config
|
||||
namespace = cotyledon
|
||||
namespace = oslo.concurrency
|
||||
namespace = oslo.db
|
||||
namespace = oslo.log
|
||||
@@ -8,4 +9,4 @@ namespace = oslo.messaging
|
||||
namespace = oslo.middleware.http_proxy_to_wsgi
|
||||
namespace = oslo.middleware.cors
|
||||
namespace = oslo.policy
|
||||
namespace = keystonemiddleware.auth_token
|
||||
namespace = keystonemiddleware.auth_token
|
||||
|
||||
Reference in New Issue
Block a user