From 0236947f47904a31b7a24b782d66eeca25b77589 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sun, 13 Oct 2024 12:12:14 +0900 Subject: [PATCH] Support file watcher to trigger GMR report Allow generating GMR report upon file trigger in addition to a signal. The feature has been available in oslo.reports since 1.11.0[1] but it can't be used in octavia without proper initialization. [1] d23e0a65b23dc77d0104075d2313de6ca22b5cae Change-Id: Ifa08d1175a696263fea2c0e434f1e8e4d76395fe Signed-off-by: Takashi Kajinami --- etc/config/octavia-config-generator.conf | 1 + octavia/cmd/agent.py | 4 +++- octavia/cmd/api.py | 13 +++++++++---- octavia/cmd/driver_agent.py | 4 +++- octavia/cmd/health_manager.py | 4 +++- octavia/cmd/house_keeping.py | 4 +++- octavia/cmd/octavia_worker.py | 4 +++- 7 files changed, 25 insertions(+), 9 deletions(-) diff --git a/etc/config/octavia-config-generator.conf b/etc/config/octavia-config-generator.conf index 78b9f6d876..c1809b8aa7 100644 --- a/etc/config/octavia-config-generator.conf +++ b/etc/config/octavia-config-generator.conf @@ -11,6 +11,7 @@ namespace = oslo.middleware.http_proxy_to_wsgi namespace = oslo.middleware.healthcheck namespace = oslo.middleware.sizelimit namespace = oslo.policy +namespace = oslo.reports namespace = keystonemiddleware.audit namespace = keystonemiddleware.auth_token namespace = cotyledon diff --git a/octavia/cmd/agent.py b/octavia/cmd/agent.py index fc7b06e9d4..636c5f1aaf 100644 --- a/octavia/cmd/agent.py +++ b/octavia/cmd/agent.py @@ -21,6 +21,7 @@ import sys import gunicorn.app.base from oslo_config import cfg from oslo_reports import guru_meditation_report as gmr +from oslo_reports import opts as gmr_opts from octavia.amphorae.backends.agent.api_server import server from octavia.amphorae.backends.health_daemon import health_daemon @@ -54,7 +55,8 @@ def main(): # comment out to improve logging service.prepare_service(sys.argv) - gmr.TextGuruMeditation.setup_autorun(version) + gmr_opts.set_defaults(CONF) + gmr.TextGuruMeditation.setup_autorun(version, conf=CONF) health_sender_proc = multiproc.Process(name='HM_sender', target=health_daemon.run_sender, diff --git a/octavia/cmd/api.py b/octavia/cmd/api.py index d39bd1bc67..7dcc43ee2c 100644 --- a/octavia/cmd/api.py +++ b/octavia/cmd/api.py @@ -18,25 +18,30 @@ from wsgiref import simple_server from oslo_config import cfg from oslo_log import log as logging from oslo_reports import guru_meditation_report as gmr +from oslo_reports import opts as gmr_opts from octavia.api import app as api_app from octavia.common import constants from octavia import version +CONF = cfg.CONF LOG = logging.getLogger(__name__) def main(): - gmr.TextGuruMeditation.setup_autorun(version) + # TODO(tkajinam): We should consider adding this to wsgi app too so that + # GMR can be used even when api is run by uwsgi/mod_wsgi/etc. + gmr_opts.set_defaults(CONF) + gmr.TextGuruMeditation.setup_autorun(version, conf=CONF) app = api_app.setup_app(argv=sys.argv) - host = cfg.CONF.api_settings.bind_host - port = cfg.CONF.api_settings.bind_port + host = CONF.api_settings.bind_host + port = CONF.api_settings.bind_port LOG.info("Starting API server on %(host)s:%(port)s", {"host": host, "port": port}) - if cfg.CONF.api_settings.auth_strategy != constants.KEYSTONE: + if CONF.api_settings.auth_strategy != constants.KEYSTONE: LOG.warning('Octavia configuration [api_settings] auth_strategy is ' 'not set to "keystone". This is not a normal ' 'configuration and you may get "Missing project ID" ' diff --git a/octavia/cmd/driver_agent.py b/octavia/cmd/driver_agent.py index 84ce5d854a..67148b3807 100644 --- a/octavia/cmd/driver_agent.py +++ b/octavia/cmd/driver_agent.py @@ -22,6 +22,7 @@ import time from oslo_config import cfg from oslo_log import log as logging from oslo_reports import guru_meditation_report as gmr +from oslo_reports import opts as gmr_opts import setproctitle from stevedore import enabled as stevedore_enabled @@ -96,7 +97,8 @@ def main(): LOG.debug('Full set of CONF:') CONF.log_opt_values(LOG, logging.DEBUG) - gmr.TextGuruMeditation.setup_autorun(version) + gmr_opts.set_defaults(CONF) + gmr.TextGuruMeditation.setup_autorun(version, conf=CONF) processes = [] exit_event = multiprocessing.Event() diff --git a/octavia/cmd/health_manager.py b/octavia/cmd/health_manager.py index 0bf1548225..86bb7e4eee 100644 --- a/octavia/cmd/health_manager.py +++ b/octavia/cmd/health_manager.py @@ -24,6 +24,7 @@ from futurist import periodics from oslo_config import cfg from oslo_log import log as logging from oslo_reports import guru_meditation_report as gmr +from oslo_reports import opts as gmr_opts from octavia.amphorae.drivers.health import heartbeat_udp from octavia.common import service @@ -90,7 +91,8 @@ def main(): LOG.debug('Full set of CONF:') CONF.log_opt_values(LOG, logging.DEBUG) - gmr.TextGuruMeditation.setup_autorun(version) + gmr_opts.set_defaults(CONF) + gmr.TextGuruMeditation.setup_autorun(version, conf=CONF) processes = [] exit_event = multiprocessing.Event() diff --git a/octavia/cmd/house_keeping.py b/octavia/cmd/house_keeping.py index 5a82a54142..8371feb0da 100644 --- a/octavia/cmd/house_keeping.py +++ b/octavia/cmd/house_keeping.py @@ -20,6 +20,7 @@ import threading from oslo_config import cfg from oslo_log import log as logging from oslo_reports import guru_meditation_report as gmr +from oslo_reports import opts as gmr_opts from oslo_utils import timeutils from octavia.common import service @@ -81,7 +82,8 @@ def main(): LOG.debug('Full set of CONF:') CONF.log_opt_values(LOG, logging.DEBUG) - gmr.TextGuruMeditation.setup_autorun(version) + gmr_opts.set_defaults(CONF) + gmr.TextGuruMeditation.setup_autorun(version, conf=CONF) timestamp = str(timeutils.utcnow()) LOG.info("Starting house keeping at %s", timestamp) diff --git a/octavia/cmd/octavia_worker.py b/octavia/cmd/octavia_worker.py index 74e603a0f6..68804990aa 100644 --- a/octavia/cmd/octavia_worker.py +++ b/octavia/cmd/octavia_worker.py @@ -18,6 +18,7 @@ import cotyledon from cotyledon import oslo_config_glue from oslo_config import cfg from oslo_reports import guru_meditation_report as gmr +from oslo_reports import opts as gmr_opts from octavia.common import service as octavia_service from octavia.controller.queue.v2 import consumer as consumer_v2 @@ -29,7 +30,8 @@ CONF = cfg.CONF def main(): octavia_service.prepare_service(sys.argv) - gmr.TextGuruMeditation.setup_autorun(version) + gmr_opts.set_defaults(CONF) + gmr.TextGuruMeditation.setup_autorun(version, conf=CONF) sm = cotyledon.ServiceManager() sm.add(consumer_v2.ConsumerService,