summaryrefslogtreecommitdiff
path: root/ceilometer/cmd
diff options
context:
space:
mode:
authorDaniel Vincze <dvincze@cloudbasesolutions.com>2018-12-06 22:19:16 +0200
committerLucian Petrut <lpetrut@cloudbasesolutions.com>2019-05-22 14:38:22 +0300
commit28f0a70da99b2fde2479ce6a5c62128ab75554af (patch)
tree064937b378260657b3897c4c23bf131413d3f1b8 /ceilometer/cmd
parent9daaf671c34e2aefaa6f1f8e1ad29c73fa7ed54c (diff)
downloadceilometer-28f0a70da99b2fde2479ce6a5c62128ab75554af.tar.gz
Windows: avoid passing conf objects to subprocesses
On Windows, cotyledon uses multiprocessing instead of forking. Meanwhile, config objects as well as service manager objects aren't pickleable. For this reason, we'll avoid passing unpickleable objects to subprocesses, making all the required initialization on the subprocess side. This change will allow ceilometer-polling to run on Windows. Change-Id: Id51db8f06f295bb7019915b53e560df52456cbda Closes-Bug: #1625602
Diffstat (limited to 'ceilometer/cmd')
-rw-r--r--ceilometer/cmd/polling.py32
1 files changed, 23 insertions, 9 deletions
diff --git a/ceilometer/cmd/polling.py b/ceilometer/cmd/polling.py
index b2fe2ac2..a1353294 100644
--- a/ceilometer/cmd/polling.py
+++ b/ceilometer/cmd/polling.py
@@ -14,6 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import os
import shlex
import cotyledon
@@ -72,18 +73,31 @@ CLI_OPTS = [
]
-def create_polling_service(worker_id, conf):
+def _prepare_config():
+ conf = cfg.ConfigOpts()
+ conf.register_cli_opts(CLI_OPTS)
+ service.prepare_service(conf=conf)
+ return conf
+
+
+def create_polling_service(worker_id, conf=None):
+ if conf is None:
+ conf = _prepare_config()
+ conf.log_opt_values(LOG, log.DEBUG)
return manager.AgentManager(worker_id,
- conf,
- conf.polling_namespaces)
+ conf)
def main():
- conf = cfg.ConfigOpts()
- conf.register_cli_opts(CLI_OPTS)
- service.prepare_service(conf=conf)
- priv_context.init(root_helper=shlex.split(utils._get_root_helper()))
sm = cotyledon.ServiceManager()
- sm.add(create_polling_service, args=(conf,))
- oslo_config_glue.setup(sm, conf)
+ # On Windows, we can only initialize conf objects in the subprocess.
+ # As a consequence, we can't use oslo_config_glue.setup() on Windows,
+ # because cotyledon.ServiceManager objects are not picklable.
+ if os.name == 'nt':
+ sm.add(create_polling_service)
+ else:
+ conf = _prepare_config()
+ priv_context.init(root_helper=shlex.split(utils._get_root_helper()))
+ oslo_config_glue.setup(sm, conf)
+ sm.add(create_polling_service, args=(conf,))
sm.run()