Skip to content

Commit

Permalink
mgr/PyModuleRegistry: log error if we can't find any modules to load
Browse files Browse the repository at this point in the history
  • Loading branch information
tserong committed May 10, 2019
1 parent d20076b commit 67a4795
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/mgr/PyModuleRegistry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ void PyModuleRegistry::init()

std::list<std::string> failed_modules;

std::set<std::string> module_names = probe_modules();
const std::string module_path = g_conf().get_val<std::string>("mgr_module_path");
std::set<std::string> module_names = probe_modules(module_path);
// Load python code
for (const auto& module_name : module_names) {
dout(1) << "Loading python module '" << module_name << "'" << dendl;
Expand All @@ -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(", "));
Expand Down Expand Up @@ -255,10 +258,8 @@ void PyModuleRegistry::shutdown()
Py_Finalize();
}

std::set<std::string> PyModuleRegistry::probe_modules() const
std::set<std::string> PyModuleRegistry::probe_modules(const std::string &path) const
{
std::string path = g_conf().get_val<std::string>("mgr_module_path");

DIR *dir = opendir(path.c_str());
if (!dir) {
return {};
Expand Down
2 changes: 1 addition & 1 deletion src/mgr/PyModuleRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PyModuleRegistry
/**
* Discover python modules from local disk
*/
std::set<std::string> probe_modules() const;
std::set<std::string> probe_modules(const std::string &path) const;

PyModuleConfig module_config;

Expand Down

0 comments on commit 67a4795

Please sign in to comment.