diff --git a/daemons/ganeti-confd b/daemons/ganeti-confd index 958e1a133e50948250b38f899628b0d668e72846..3a685c78e2682eeda7eb46d0e26664b5df003ca2 100755 --- a/daemons/ganeti-confd +++ b/daemons/ganeti-confd @@ -117,7 +117,8 @@ class ConfdConfigurationReloader(object): self.inotify_handler = asyncnotifier.SingleFileEventHandler(self.wm, self.OnInotify, cfg_file) - self.notifier = asyncnotifier.AsyncNotifier(self.wm, self.inotify_handler) + notifier_class = asyncnotifier.ErrorLoggingAsyncNotifier + self.notifier = notifier_class(self.wm, self.inotify_handler) self.timer_handle = None self._EnableTimer() diff --git a/lib/asyncnotifier.py b/lib/asyncnotifier.py index 421e476dba9de643556d934ccc7482e6e0952fb1..286cd2fd2278cb43ebc8561010e5b7a19efff21a 100644 --- a/lib/asyncnotifier.py +++ b/lib/asyncnotifier.py @@ -31,6 +31,7 @@ try: except ImportError: import pyinotify +from ganeti import daemon from ganeti import errors # We contributed the AsyncNotifier class back to python-pyinotify, and it's @@ -65,6 +66,16 @@ class AsyncNotifier(asyncore.file_dispatcher): self.notifier.process_events() +class ErrorLoggingAsyncNotifier(AsyncNotifier, + daemon.GanetiBaseAsyncoreDispatcher): + """An asyncnotifier that can survive errors in the callbacks. + + We define this as a separate class, since we don't want to make AsyncNotifier + diverge from what we contributed upstream. + + """ + + class SingleFileEventHandler(pyinotify.ProcessEvent): """Handle modify events for a single file. diff --git a/test/ganeti.asyncnotifier_unittest.py b/test/ganeti.asyncnotifier_unittest.py index b379ba1efff8d77f459938d8a8f4f6552be3c995..f5e7f73374763cf30370429482676d1a2d8c113a 100755 --- a/test/ganeti.asyncnotifier_unittest.py +++ b/test/ganeti.asyncnotifier_unittest.py @@ -57,8 +57,8 @@ class TestSingleFileEventHandler(testutils.GanetiTestCase): self.cbk[i], self.chk_files[i]) for i in range(len(self.NOTIFIERS))] - self.notifiers = [asyncnotifier.AsyncNotifier(self.wms[i], - self.ihandler[i]) + self.notifiers = [asyncnotifier.ErrorLoggingAsyncNotifier(self.wms[i], + self.ihandler[i]) for i in range(len(self.NOTIFIERS))] # TERM notifier is enabled by default, as we use it to get out of the loop self.ihandler[self.NOTIFIER_TERM].enable()