Reraise exception and log error message

When the sysinv_api_workers is configured incorrect, the
sysinv api will not start due to the invalid default value.
therefore will cause host swact.

In this case, we can hardly figure out why that node is
failure, This patch is to catch exception and log error
message and then reraise exception if sysinv_api_workers
is invalid value.

Closes-bug: #1835142
Change-Id: Ie8dd185a6a24aec28c8834d5013cc003a1f7792f
Signed-off-by: junboli <junbo85.li@gmail.com>
This commit is contained in:
junboli 2019-07-09 02:24:33 -04:00 committed by junbo.li
parent 33df6b67ab
commit c38efebf91
1 changed files with 14 additions and 5 deletions

View File

@ -21,9 +21,11 @@
"""The SysInv Service API."""
import six
import sys
from oslo_config import cfg
from oslo_log import log
from sysinv.common import exception
from sysinv.common import service as sysinv_service
from sysinv.common import wsgi_service
from sysinv import sanity_coverage
@ -37,11 +39,18 @@ def sysinv_api():
launcher = sysinv_service.process_launcher()
# server for API
workers = CONF.sysinv_api_workers or 2
server = wsgi_service.WSGIService('sysinv_api',
CONF.sysinv_api_bind_ip,
CONF.sysinv_api_port,
workers,
False)
server = None
try:
server = wsgi_service.WSGIService('sysinv_api',
CONF.sysinv_api_bind_ip,
CONF.sysinv_api_port,
workers,
False)
except exception.ConfigInvalid as e:
LOG.error(six.text_type(e))
raise
launcher.launch_service(server, workers=server.workers)
return launcher