From dcb4355e59de24481c2b669ccce54f3b7dba7ff1 Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Thu, 19 Jul 2018 15:18:03 +0800 Subject: [PATCH] Use register_session_conf_options API Using this API is needed to correctly initialize the configuration. [keystone_authtoken] group is used for keystonemiddleware to validating token. The new [keystone] group is used for keystoneauth to initialization the keystone session. Co-Authored-By: wangxiyuan Change-Id: Ie3ab512b0ab42c0f97b3099e0787f4edee08ddce Partial-Bug: #1775140 --- mistral/cmd/launch.py | 18 ++++++++++++++++++ mistral/config.py | 3 +++ mistral/utils/openstack/keystone.py | 7 ++----- ...d-keystoneauth-option-d9657d3052e82125.yaml | 11 +++++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/load-keystoneauth-option-d9657d3052e82125.yaml diff --git a/mistral/cmd/launch.py b/mistral/cmd/launch.py index 54eb74c3f..994982dfb 100644 --- a/mistral/cmd/launch.py +++ b/mistral/cmd/launch.py @@ -56,6 +56,8 @@ CONF = cfg.CONF SERVER_THREAD_MANAGER = None SERVER_PROCESS_MANAGER = None +LOG = logging.getLogger(__name__) + def launch_thread(server, workers=1): try: @@ -176,12 +178,28 @@ def get_properly_ordered_parameters(): return args +def override_keystone_options(): + # TODO(wxy): This function is used for keeping backward compatibility. + # Remove it in Stein. + auth_opts = CONF['keystone_authtoken'] + for opt, value in auth_opts.items(): + if opt in CONF['keystone']: + default_value = auth_opts._group._opts[opt]['opt'].default + if default_value != value != CONF['keystone'][opt]: + LOG.warning("The config option '%s' in section " + "[keystone_authtoken] has the same copy in " + "[keystone]. Please add the same option to the " + "[keystone] section to keep using it.", opt) + CONF.set_override(opt, value, group='keystone') + + def main(): try: config.parse_args(get_properly_ordered_parameters()) print_server_info() logging.setup(CONF, 'Mistral') + override_keystone_options() # Please refer to the oslo.messaging documentation for transport # configuration. The default transport for oslo.messaging is diff --git a/mistral/config.py b/mistral/config.py index ad4aab494..deb4107ab 100644 --- a/mistral/config.py +++ b/mistral/config.py @@ -21,6 +21,7 @@ Configuration options registration and useful routines. import itertools import os +from keystoneauth1 import loading from oslo_config import cfg from oslo_log import log from oslo_middleware import cors @@ -560,6 +561,7 @@ PROFILER_GROUP = profiler.list_opts()[0][0] KEYCLOAK_OIDC_GROUP = "keycloak_oidc" OPENSTACK_ACTIONS_GROUP = 'openstack_actions' YAQL_GROUP = "yaql" +KEYSTONE_GROUP = "keystone" CONF.register_opt(wf_trace_log_name_opt) @@ -591,6 +593,7 @@ CONF.register_opts(profiler_opts, group=PROFILER_GROUP) CONF.register_opts(keycloak_oidc_opts, group=KEYCLOAK_OIDC_GROUP) CONF.register_opts(openstack_actions_opts, group=OPENSTACK_ACTIONS_GROUP) CONF.register_opts(yaql_opts, group=YAQL_GROUP) +loading.register_session_conf_options(CONF, KEYSTONE_GROUP) CLI_OPTS = [ use_debugger_opt, diff --git a/mistral/utils/openstack/keystone.py b/mistral/utils/openstack/keystone.py index b650fed9b..f5410ac4d 100644 --- a/mistral/utils/openstack/keystone.py +++ b/mistral/utils/openstack/keystone.py @@ -28,9 +28,6 @@ from mistral import context from mistral import exceptions CONF = cfg.CONF -CONF.register_opt(cfg.IntOpt('timeout'), group='keystone_authtoken') -CONF.register_opt(cfg.BoolOpt('collect_timing'), group='keystone_authtoken') -CONF.register_opt(cfg.BoolOpt('split_loggers'), group='keystone_authtoken') def client(): @@ -136,7 +133,7 @@ def _admin_client(trust_id=None): ) sess = loading.load_session_from_conf_options( CONF, - 'keystone_authtoken', + 'keystone', auth=auth ) @@ -292,7 +289,7 @@ def get_admin_session(): return loading.load_session_from_conf_options( CONF, - 'keystone_authtoken', + 'keystone', auth=auth ) diff --git a/releasenotes/notes/load-keystoneauth-option-d9657d3052e82125.yaml b/releasenotes/notes/load-keystoneauth-option-d9657d3052e82125.yaml new file mode 100644 index 000000000..049e49e9b --- /dev/null +++ b/releasenotes/notes/load-keystoneauth-option-d9657d3052e82125.yaml @@ -0,0 +1,11 @@ +--- +fixes: + - | + A new config option section `[keystone]` is added. The options in the + section is from keystoneauth by default. Please use them to talk with + keystone session. If the option value is not set, to keep backward + compatibility, Mistral will read the value from the same option in + `[keystone_authtoken]`. + + The override behvaior will be removed in Stein. Please update the options + into `[keystone]` if you still want to use them.