From 677f4fba18d8921e8616e44a0db843869b7c828b Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Fri, 1 Aug 2025 18:25:35 +0900 Subject: [PATCH] Parse server option while parsing its input ... to give more early and clear feedback to users. Change-Id: I7633714dfc640ec7f18a963538e33df55ac20660 Signed-off-by: Takashi Kajinami --- mistral/cmd/launch.py | 25 +++++++++---------------- mistral/config.py | 8 +++++--- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/mistral/cmd/launch.py b/mistral/cmd/launch.py index 421d05f5c..c540dbd6c 100644 --- a/mistral/cmd/launch.py +++ b/mistral/cmd/launch.py @@ -134,12 +134,17 @@ Mistral Workflow Service, version %s """ % version.version_string +def _get_server(): + server = cfg.CONF.server + if 'all' in server: + return set(LAUNCH_OPTIONS.keys()) + return set(cfg.CONF.server) + + def print_server_info(): print(MISTRAL_TITLE) - comp_str = ("[%s]" % ','.join(LAUNCH_OPTIONS - if cfg.CONF.server == ['all'] else cfg.CONF.server)) - + comp_str = "[%s]" % ','.join(_get_server()) print('Launching server components %s...' % comp_str) @@ -197,19 +202,7 @@ def main(): # processes because the "fake" transport is using an in process queue. rpc.get_transport() - if cfg.CONF.server == ['all']: - # Launch all servers. - launch_any(LAUNCH_OPTIONS.keys()) - else: - # Validate launch option. - if set(cfg.CONF.server) - set(LAUNCH_OPTIONS.keys()): - raise Exception( - "Valid options are 'all' or any combination of [%s]" % - ', '.join(LAUNCH_OPTIONS.keys()) - ) - - # Launch distinct set of server(s). - launch_any(set(cfg.CONF.server)) + launch_any(_get_server()) except RuntimeError as excp: sys.stderr.write("ERROR: %s\n" % excp) diff --git a/mistral/config.py b/mistral/config.py index 15da48e5e..3c520193e 100644 --- a/mistral/config.py +++ b/mistral/config.py @@ -24,6 +24,7 @@ import json from keystoneauth1 import loading from oslo_config import cfg +from oslo_config import types from oslo_log import log from oslo_middleware import cors from oslo_service import _options as service_opts @@ -38,9 +39,10 @@ from mistral.workflow import states launch_opt = cfg.ListOpt( 'server', default=['all'], - help=_('Specifies which mistral server to start by the launch script. ' - 'Valid options are all or any combination of ' - 'api, engine, and executor.') + item_type=types.String( + choices=('all', 'api', 'engine', 'executor', 'event-engine', + 'notifier')), + help=_('Specifies which mistral server to start by the launch script.') ) wf_trace_log_name_opt = cfg.StrOpt(