[sources] Skip problematic sources when starting shell instead of crashing. Closes #3670208
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 20 Mar 2014 08:45:52 +0100
changeset 9602 9fb2f15d5e85
parent 9601 e5a80bd337e8
child 9603 1676d316171d
[sources] Skip problematic sources when starting shell instead of crashing. Closes #3670208 At least this gives an opportunity to fix the problem in using c-c shell, which is currently not possible because it crashes during initialization. Notice that since sources are copy based, it should not be a problem at all to have some disabled, beside for services such as authentication sources as ldapfeed.
server/repository.py
--- a/server/repository.py	Fri Apr 04 17:32:12 2014 +0200
+++ b/server/repository.py	Thu Mar 20 08:45:52 2014 +0100
@@ -282,8 +282,14 @@
         clear_cache(self, 'source_defs')
 
     def add_source(self, sourceent):
-        source = self.get_source(sourceent.type, sourceent.name,
-                                 sourceent.host_config, sourceent.eid)
+        try:
+            source = self.get_source(sourceent.type, sourceent.name,
+                                     sourceent.host_config, sourceent.eid)
+        except RuntimeError:
+            if self.config.repairing:
+                self.exception('cant setup source %s, skipped', sourceent.name)
+                return
+            raise
         self.sources_by_eid[sourceent.eid] = source
         self.sources_by_uri[sourceent.name] = source
         if self.config.source_enabled(source):