Skip to content
Snippets Groups Projects
Commit d021e478 authored by Guido Trotter's avatar Guido Trotter
Browse files

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: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 17496050
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment