From cf5ef59bcc435371c9f1a8ccc784792a9388a5fe Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 23 Apr 2018 17:09:37 -0400 Subject: [PATCH] mgr: execute modules even if can_run=false We execute modules even if can_run=false, so that it is possible to load them for running their selftest hooks. However, we already raise health messages about the fact that they're enabled but can't run, so we don't want to also raise health messages about whatever exceptions they raise from serve() Signed-off-by: John Spray --- src/mgr/PyModuleRegistry.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mgr/PyModuleRegistry.cc b/src/mgr/PyModuleRegistry.cc index 2364b1cfb8b..bd05a68ed73 100644 --- a/src/mgr/PyModuleRegistry.cc +++ b/src/mgr/PyModuleRegistry.cc @@ -195,7 +195,7 @@ void PyModuleRegistry::active_start( for (const auto &i : modules) { // Anything we're skipping because of !can_run will be flagged // to the user separately via get_health_checks - if (!(i.second->is_enabled() && i.second->get_can_run())) { + if (!(i.second->is_enabled() && i.second->is_loaded())) { continue; } @@ -353,7 +353,13 @@ void PyModuleRegistry::get_health_checks(health_check_map_t *checks) if (module->is_enabled() && !module->get_can_run()) { dependency_modules[module->get_name()] = module->get_error_string(); } else if ((module->is_enabled() && !module->is_loaded()) - || module->is_failed()) { + || (module->is_failed() && module->get_can_run())) { + // - Unloadable modules are only reported if they're enabled, + // to avoid spamming users about modules they don't have the + // dependencies installed for because they don't use it. + // - Failed modules are only reported if they passed the can_run + // checks (to avoid outputting two health messages about a + // module that said can_run=false but we tried running it anyway) failed_modules[module->get_name()] = module->get_error_string(); } } -- 2.39.5