From cea0534a8749d38182f83d1a8a0b245259d95645 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Thu, 28 Jan 2010 14:40:44 +0000
Subject: [PATCH] Fix flipping MC flag bug

Currently unofflining or undraining an already functional master
candidate node, can cause it to demote itself. In order to avoid that we
only trigger the self-promotion check if the node is not currently a
candidate.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/cmdlib.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 4f8a8f296..a063e9da4 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -3203,7 +3203,7 @@ class LUSetNodeParams(LogicalUnit):
 
     # If we're being deofflined/drained, we'll MC ourself if needed
     if (deoffline_or_drain and not offline_or_drain and not
-        self.op.master_candidate == True):
+        self.op.master_candidate == True and not node.master_candidate):
       self.op.master_candidate = _DecideSelfPromotion(self)
       if self.op.master_candidate:
         self.LogInfo("Autopromoting node to master candidate")
-- 
GitLab