From 67a47951053bbca0d5951ac3f49fd99d100a9d14 Mon Sep 17 00:00:00 2001 From: Tim Serong Date: Fri, 10 May 2019 15:08:30 +1000 Subject: [PATCH] mgr/PyModuleRegistry: log error if we can't find any modules to load Fixes: https://tracker.ceph.com/issues/39662 Signed-off-by: Tim Serong --- src/mgr/PyModuleRegistry.cc | 11 ++++++----- src/mgr/PyModuleRegistry.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mgr/PyModuleRegistry.cc b/src/mgr/PyModuleRegistry.cc index 785b5d3ab45..061a92c6c7c 100644 --- a/src/mgr/PyModuleRegistry.cc +++ b/src/mgr/PyModuleRegistry.cc @@ -66,7 +66,8 @@ void PyModuleRegistry::init() std::list failed_modules; - std::set module_names = probe_modules(); + const std::string module_path = g_conf().get_val("mgr_module_path"); + std::set module_names = probe_modules(module_path); // Load python code for (const auto& module_name : module_names) { dout(1) << "Loading python module '" << module_name << "'" << dendl; @@ -88,7 +89,9 @@ void PyModuleRegistry::init() // report its loading error modules[module_name] = std::move(mod); } - + if (module_names.empty()) { + clog->error() << "No ceph-mgr modules found in " << module_path; + } if (!failed_modules.empty()) { clog->error() << "Failed to load ceph-mgr modules: " << joinify( failed_modules.begin(), failed_modules.end(), std::string(", ")); @@ -255,10 +258,8 @@ void PyModuleRegistry::shutdown() Py_Finalize(); } -std::set PyModuleRegistry::probe_modules() const +std::set PyModuleRegistry::probe_modules(const std::string &path) const { - std::string path = g_conf().get_val("mgr_module_path"); - DIR *dir = opendir(path.c_str()); if (!dir) { return {}; diff --git a/src/mgr/PyModuleRegistry.h b/src/mgr/PyModuleRegistry.h index 0e46af44e6e..52e9907e361 100644 --- a/src/mgr/PyModuleRegistry.h +++ b/src/mgr/PyModuleRegistry.h @@ -55,7 +55,7 @@ private: /** * Discover python modules from local disk */ - std::set probe_modules() const; + std::set probe_modules(const std::string &path) const; PyModuleConfig module_config; -- 2.39.5