From 2fb96d392cd7206bc1e3340975044aeef1da60d5 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 18 Jun 2008 12:31:53 +0000 Subject: [PATCH] ganeti-watcher: Don't write file if data didn't change This is the safest way to detect changes and the amount of data is small, so keeping a copy around is cheap enough. Reviewed-by: iustinp --- daemons/ganeti-watcher | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/daemons/ganeti-watcher b/daemons/ganeti-watcher index a8ae05889..a6f113fa6 100755 --- a/daemons/ganeti-watcher +++ b/daemons/ganeti-watcher @@ -136,12 +136,19 @@ class WatcherState(object): if "node" not in self._data: self._data["node"] = {} + self._orig_data = self._data.copy() + def Save(self): """Save state to file, then unlock and close it. """ assert self.statefile + if self._orig_data == self._data: + logging.debug("Data didn't change, just touching status file") + os.utime(constants.WATCHER_STATEFILE, None) + return + # We need to make sure the file is locked before renaming it, otherwise # starting ganeti-watcher again at the same time will create a conflict. fd = utils.WriteFile(constants.WATCHER_STATEFILE, -- GitLab