Verify if we're master before demoting
authorKlaus Aehlig <aehlig@google.com>
Mon, 30 Mar 2015 12:36:23 +0000 (14:36 +0200)
committerKlaus Aehlig <aehlig@google.com>
Tue, 31 Mar 2015 08:07:51 +0000 (10:07 +0200)
...as the master node should never lose it's master capability.
Fixes issue 1023.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

lib/cmdlib/node.py

index 89a9aee..5b90ad3 100644 (file)
@@ -647,6 +647,9 @@ class LUNodeSetParams(LogicalUnit):
 
     # If we're no longer master capable, we'll demote ourselves from MC
     if self.op.master_capable is False and node.master_candidate:
 
     # If we're no longer master capable, we'll demote ourselves from MC
     if self.op.master_capable is False and node.master_candidate:
+      if self.op.node_uuid == self.cfg.GetMasterNode():
+        raise errors.OpPrereqError("Master must remain master capable",
+                                   errors.ECODE_STATE)
       self.LogInfo("Demoting from master candidate")
       self.op.master_candidate = False
 
       self.LogInfo("Demoting from master candidate")
       self.op.master_candidate = False