SingleFileEventHandler: update comments
authorGuido Trotter <ultrotter@google.com>
Fri, 21 May 2010 11:45:56 +0000 (12:45 +0100)
committerGuido Trotter <ultrotter@google.com>
Sat, 22 May 2010 06:58:27 +0000 (07:58 +0100)
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 <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/asyncnotifier.py

index b576a5d..421e476 100644 (file)
@@ -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: