Currently, when draining nodes we reset their master candidate flag, but
we don't instruct them to demote themselves. This least to “ERROR: file
'/var/lib/ganeti/config.data' should not exist on non master candidates
(and the file is outdated)”.

This patch simply adds a call to node_demote_from_mc in this case.
---
 lib/cmdlib.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index f556677..cb3bb31 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -2459,16 +2459,20 @@ class LUSetNodeParams(LogicalUnit):
     if self.op.drained is not None:
       node.drained = self.op.drained
       result.append(("drained", str(self.op.drained)))
       if self.op.drained == True:
         if node.master_candidate:
           node.master_candidate = False
           changed_mc = True
           result.append(("master_candidate", "auto-demotion due to drain"))
+          rrc = self.rpc.call_node_demote_from_mc(node.name)
+          msg = rrc.RemoteFailMsg()
+          if msg:
+            self.LogWarning("Node failed to demote itself: %s" % msg)
         if node.offline:
           node.offline = False
           result.append(("offline", "clear offline status due to drain"))
 
     # this will trigger configuration file update, if needed
     self.cfg.Update(node)
     # this will trigger job queue propagation or cleanup
     if changed_mc:
-- 
1.6.3.3

Reply via email to