From d021e47813dd73f7bd0537497ea5b761c3439553 Mon Sep 17 00:00:00 2001 From: Guido Trotter Date: Fri, 21 May 2010 12:45:56 +0100 Subject: [PATCH] SingleFileEventHandler: update comments The comments in the SingleFileEventHandler are still confd-specific. Update them to make them generic for any single-file monitoring. Signed-off-by: Guido Trotter Reviewed-by: Iustin Pop --- lib/asyncnotifier.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/lib/asyncnotifier.py b/lib/asyncnotifier.py index b576a5d..421e476 100644 --- a/lib/asyncnotifier.py +++ b/lib/asyncnotifier.py @@ -113,20 +113,17 @@ class SingleFileEventHandler(pyinotify.ProcessEvent): # pylint: disable-msg=C0103 # this overrides a method in pyinotify.ProcessEvent def process_IN_IGNORED(self, event): - # Due to the fact that we monitor just for the cluster config file (rather - # than for the whole data dir) when the file is replaced with another one - # (which is what happens normally in ganeti) we're going to receive an - # IN_IGNORED event from inotify, because of the file removal (which is - # contextual with the replacement). In such a case we need to create - # another watcher for the "new" file. + # Since we monitor a single file rather than the directory it resides in, + # when that file is replaced with another one (which is what happens when + # utils.WriteFile, the most normal way of updating files in ganeti, is + # called) we're going to receive an IN_IGNORED event from inotify, because + # of the file removal (which is contextual with the replacement). In such a + # case we'll need to create a watcher for the "new" file. This can be done + # by the callback by calling "enable" again on us. logging.debug("Received 'ignored' inotify event for %s", event.path) self.watch_handle = None try: - # Since the kernel believes the file we were interested in is gone, it's - # not going to notify us of any other events, until we set up, here, the - # new watch. This is not a race condition, though, since we're anyway - # going to realod the file after setting up the new watch. self.callback(False) except: # pylint: disable-msg=W0702 # we need to catch any exception here, log it, but proceed, because even @@ -137,10 +134,10 @@ class SingleFileEventHandler(pyinotify.ProcessEvent): # pylint: disable-msg=C0103 # this overrides a method in pyinotify.ProcessEvent def process_IN_MODIFY(self, event): - # This gets called when the config file is modified. Note that this doesn't - # usually happen in Ganeti, as the config file is normally replaced by a - # new one, at filesystem level, rather than actually modified (see - # utils.WriteFile) + # This gets called when the monitored file is modified. Note that this + # doesn't usually happen in Ganeti, as most of the time we're just + # replacing any file with a new one, at filesystem level, rather than + # actually changing it. (see utils.WriteFile) logging.debug("Received 'modify' inotify event for %s", event.path) try: -- 1.7.10.4