From eee1fa2d1542f7be58892b8f8207136f10d86959 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 13 May 2008 09:48:15 +0000
Subject: [PATCH] Watcher: do not activate disks for started instances

Currently the watcher runs first the instance startup and then the
boot-id method of disk reactivation. However, irrelevant of the fact
that a node has rebooted or not, if we just started an instance, there's
no need for its disks to be activated again, since the start instance
has done that (if it is at all possible).

The patch modifies the watcher to remember all started instances and not
run activate-disks for them.

Reviewed-by: ultrotter
---
 daemons/ganeti-watcher | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/daemons/ganeti-watcher b/daemons/ganeti-watcher
index b81e7e812..c865e9899 100755
--- a/daemons/ganeti-watcher
+++ b/daemons/ganeti-watcher
@@ -344,6 +344,7 @@ class Watcher(object):
     self.instances = GetInstanceList()
     self.bootids = GetNodeBootIDs()
     self.messages = []
+    self.started_instances = set()
 
   def Run(self):
     notepad = WatcherState()
@@ -373,6 +374,10 @@ class Watcher(object):
                                         " non-autostart instance '%s'." %
                                         instance.name)))
           continue
+        if instance.name in self.started_instances:
+          # we already tried to start the instance, which should have
+          # activated its drives (if they can be at all)
+          continue
         try:
           self.messages.append(Message(NOTICE, ("Activating disks for %s." %
                                                 instance.name)))
@@ -411,6 +416,7 @@ class Watcher(object):
           self.messages.append(Message(NOTICE, ("Restarting %s%s." %
                                                 (instance.name, last))))
           instance.Restart()
+          self.started_instances.add(instance.name)
         except Error, x:
           self.messages.append(Message(ERROR, str(x)))
 
-- 
GitLab