diff options
author | Ruby Loo <ruby.loo@intel.com> | 2016-09-13 17:46:27 -0400 |
---|---|---|
committer | Ruby Loo <ruby.loo@intel.com> | 2016-09-15 11:14:20 -0400 |
commit | ec202c444ba159797403407c771e24fbc2ddcd4f (patch) | |
tree | 1ad35cbafbd198f82d92ba361d06b2330693786e /ironic/cmd | |
parent | 57d4e0ce3d18f738c1fbe7453421833f9712f534 (diff) | |
download | ironic-ec202c444ba159797403407c771e24fbc2ddcd4f.tar.gz |
Separate WSGIService from RPCService
This patch fixes a problem which prevented Ironic from honoring the
interval values configuration for the periodic tasks. Since the interval
values are passed to a decorator, the configuration options should be
evaluated prior to importing the module which contains the periodic tasks.
In our case this was not happening due to the chain of imports going
from ironic.cmd.conductor -> ironic.common.service -> ironic.api.app
-> ... -> ironic.conductor.manager. This caused the @periodic
decorators to be evaluated before the configuration options were loaded.
This patch breaks that chain of imports by separating the WSGIService
and RPCService classes into two separate files. The conductor uses the
RPCService, and since it is now in a separate file from WSGIService, it
no longer pulls in ironic.api.app, ..., and ironic.conductor.manager.
(ironic.api.app was being imported because WSGIService needed it.)
Change-Id: Ie318e7bb2d2c2d971a796ab8960be33fccbd88f3
Closes-Bug: #1562258
Co-Authored-By: Lucas Alvares Gomes <lucasagomes@gmail.com>
Diffstat (limited to 'ironic/cmd')
-rw-r--r-- | ironic/cmd/api.py | 3 | ||||
-rw-r--r-- | ironic/cmd/conductor.py | 15 |
2 files changed, 14 insertions, 4 deletions
diff --git a/ironic/cmd/api.py b/ironic/cmd/api.py index fe2a058eb..e95bd8c51 100644 --- a/ironic/cmd/api.py +++ b/ironic/cmd/api.py @@ -22,6 +22,7 @@ import sys from oslo_config import cfg from ironic.common import service as ironic_service +from ironic.common import wsgi_service from ironic.objects import base from ironic.objects import indirection @@ -38,7 +39,7 @@ def main(): # Build and start the WSGI app launcher = ironic_service.process_launcher() - server = ironic_service.WSGIService('ironic_api', CONF.api.enable_ssl_api) + server = wsgi_service.WSGIService('ironic_api', CONF.api.enable_ssl_api) launcher.launch_service(server, workers=server.workers) launcher.wait() diff --git a/ironic/cmd/conductor.py b/ironic/cmd/conductor.py index 14728a5a2..57dc90567 100644 --- a/ironic/cmd/conductor.py +++ b/ironic/cmd/conductor.py @@ -26,6 +26,7 @@ from oslo_log import log from oslo_service import service from ironic.common.i18n import _LW +from ironic.common import rpc_service from ironic.common import service as ironic_service from ironic.conf import auth @@ -58,12 +59,20 @@ def _check_auth_options(conf): def main(): + # NOTE(lucasagomes): Safeguard to prevent 'ironic.conductor.manager' + # from being imported prior to the configuration options being loaded. + # If this happened, the periodic decorators would always use the + # default values of the options instead of the configured ones. For + # more information see: https://bugs.launchpad.net/ironic/+bug/1562258 + # and https://bugs.launchpad.net/ironic/+bug/1279774. + assert 'ironic.conductor.manager' not in sys.modules + # Parse config file and command line options, then start logging ironic_service.prepare_service(sys.argv) - mgr = ironic_service.RPCService(CONF.host, - 'ironic.conductor.manager', - 'ConductorManager') + mgr = rpc_service.RPCService(CONF.host, + 'ironic.conductor.manager', + 'ConductorManager') _check_auth_options(CONF) |