#5 setroubleshootd fails to start if /usr/share/setroubleshoot/plugins/ is empty
Closed: Fixed Opened by bigon.

Hi,

If /usr/share/setroubleshoot/plugins/ doesn't exist or if it doesn't contain a __init__.py file, setroubleshootd fails to start.

IMVHO if there is plugins installed at all, setroubleshootd should just continue

jui 12 15:20:01 valinor setroubleshoot[12869]: failed to load __init__ plugin
jui 12 15:20:01 valinor setroubleshoot[12869]: Traceback (most recent call last):
jui 12 15:20:01 valinor setroubleshoot[12869]:   File "/usr/lib/python3/dist-packages/setroubleshoot/server.py", line 771, in RunFaultServer
jui 12 15:20:01 valinor setroubleshoot[12869]:     analyze_thread = AnalyzeThread(analysis_queue)
jui 12 15:20:01 valinor setroubleshoot[12869]:   File "/usr/lib/python3/dist-packages/setroubleshoot/analyze.py", line 220, in __init__
jui 12 15:20:01 valinor setroubleshoot[12869]:     Analyze.__init__(self)
jui 12 15:20:01 valinor setroubleshoot[12869]:   File "/usr/lib/python3/dist-packages/setroubleshoot/analyze.py", line 135, in __init__
jui 12 15:20:01 valinor setroubleshoot[12869]:     self.plugins = load_plugins()
jui 12 15:20:01 valinor setroubleshoot[12869]:   File "/usr/lib/python3/dist-packages/setroubleshoot/util.py", line 488, in load_plugins
jui 12 15:20:01 valinor setroubleshoot[12869]:     if mod_fp:
jui 12 15:20:01 valinor setroubleshoot[12869]: UnboundLocalError: local variable 'mod_fp' referenced before assignment
jui 12 15:20:01 valinor setroubleshoot[12869]: exception UnboundLocalError: local variable 'mod_fp' referenced before assignment

Thanks for the report. The following patch should fix it:

--- a/framework/src/setroubleshoot/util.py
+++ b/framework/src/setroubleshoot/util.py
@@ -484,6 +484,7 @@ def load_plugins(filter_glob=None):
             mod = imp.load_module(module_name, mod_fp, mod_path, mod_description)
         except Exception:
             syslog.syslog(syslog.LOG_ERR, "failed to load %s plugin" % plugin_name)
+            return []
         if mod_fp:
             mod_fp.close()

I'll do some testing and push it when it's ready.

Metadata Update from @plautrba:
- Issue assigned to plautrba

Commit e9e28721 fixes this issue

Metadata