Blame SOURCES/bz1225423-01-allow-to-remove-a-dead-node-from-a-cluster.patch

15f218
From 2a080e5986331989a3164a35129e576641b2cca5 Mon Sep 17 00:00:00 2001
15f218
From: Tomas Jelinek <tojeline@redhat.com>
15f218
Date: Tue, 19 Jul 2016 16:42:44 +0200
15f218
Subject: [PATCH 1/2] allow to remove a dead node from a cluster
15f218
15f218
---
15f218
 pcs/cluster.py | 41 +++++++++++++++++++++++++++--------------
15f218
 1 file changed, 27 insertions(+), 14 deletions(-)
15f218
15f218
diff --git a/pcs/cluster.py b/pcs/cluster.py
15f218
index baa0f44..7a8615d 100644
15f218
--- a/pcs/cluster.py
15f218
+++ b/pcs/cluster.py
15f218
@@ -1076,7 +1076,7 @@ def disable_cluster_nodes(nodes):
15f218
     if len(error_list) > 0:
15f218
         utils.err("unable to disable all nodes\n" + "\n".join(error_list))
15f218
 
15f218
-def destroy_cluster(argv):
15f218
+def destroy_cluster(argv, keep_going=False):
15f218
     if len(argv) > 0:
15f218
         # stop pacemaker and resources while cluster is still quorate
15f218
         nodes = argv
15f218
@@ -1085,7 +1085,14 @@ def destroy_cluster(argv):
15f218
         # destroy will stop any remaining cluster daemons
15f218
         error_list = parallel_for_nodes(utils.destroyCluster, nodes, quiet=True)
15f218
         if error_list:
15f218
-            utils.err("unable to destroy cluster\n" + "\n".join(error_list))
15f218
+            if keep_going:
15f218
+                print(
15f218
+                    "Warning: unable to destroy cluster\n"
15f218
+                    +
15f218
+                    "\n".join(error_list)
15f218
+                )
15f218
+            else:
15f218
+                utils.err("unable to destroy cluster\n" + "\n".join(error_list))
15f218
 
15f218
 def stop_cluster(argv):
15f218
     if len(argv) > 0:
15f218
@@ -1347,19 +1354,25 @@ def cluster_node(argv):
15f218
 
15f218
     node = argv[1]
15f218
     node0, node1 = utils.parse_multiring_node(node)
15f218
-
15f218
     if not node0:
15f218
         utils.err("missing ring 0 address of the node")
15f218
-    status,output = utils.checkAuthorization(node0)
15f218
-    if status == 2:
15f218
-        utils.err("pcsd is not running on %s" % node0)
15f218
-    elif status == 3:
15f218
-        utils.err(
15f218
-            "%s is not yet authenticated (try pcs cluster auth %s)"
15f218
-            % (node0, node0)
15f218
-        )
15f218
-    elif status != 0:
15f218
-        utils.err(output)
15f218
+
15f218
+    # allow to continue if removing a node with --force
15f218
+    if add_node or "--force" not in utils.pcs_options:
15f218
+        status, output = utils.checkAuthorization(node0)
15f218
+        if status != 0:
15f218
+            if status == 2:
15f218
+                msg = "pcsd is not running on {0}".format(node0)
15f218
+            elif status == 3:
15f218
+                msg = (
15f218
+                    "{node} is not yet authenticated "
15f218
+                    + " (try pcs cluster auth {node})"
15f218
+                ).format(node=node0)
15f218
+            else:
15f218
+                msg = output
15f218
+            if not add_node:
15f218
+                msg += ", use --force to override"
15f218
+            utils.err(msg)
15f218
 
15f218
     if add_node == True:
15f218
         wait = False
15f218
@@ -1540,7 +1553,7 @@ def cluster_node(argv):
15f218
 
15f218
         nodesRemoved = False
15f218
         c_nodes = utils.getNodesFromCorosyncConf()
15f218
-        destroy_cluster([node0])
15f218
+        destroy_cluster([node0], keep_going=("--force" in utils.pcs_options))
15f218
         for my_node in c_nodes:
15f218
             if my_node == node0:
15f218
                 continue
15f218
-- 
15f218
1.8.3.1
15f218
15f218
15f218
From c48716233ace08c16e7e4b66075aebeca9366321 Mon Sep 17 00:00:00 2001
15f218
From: Tomas Jelinek <tojeline@redhat.com>
15f218
Date: Wed, 20 Jul 2016 10:01:13 +0200
15f218
Subject: [PATCH 2/2] gui: allow to remove a dead node from a cluster
15f218
15f218
---
15f218
 pcsd/remote.rb | 11 +++++++++--
15f218
 1 file changed, 9 insertions(+), 2 deletions(-)
15f218
15f218
diff --git a/pcsd/remote.rb b/pcsd/remote.rb
15f218
index 25fb74d..05a6d03 100644
15f218
--- a/pcsd/remote.rb
15f218
+++ b/pcsd/remote.rb
15f218
@@ -837,8 +837,15 @@ def remote_remove_nodes(params, request, auth_user)
15f218
   stdout, stderr, retval = run_cmd(
15f218
     auth_user, PCS, "cluster", "stop", *stop_params
15f218
   )
15f218
-  if retval != 0
15f218
-    return [400, stderr.join]
15f218
+  if retval != 0 and not params['force']
15f218
+    # If forced, keep going even if unable to stop all nodes (they may be dead).
15f218
+    # Add info this error is forceable if pcs did not do it (e.g. when unable
15f218
+    # to connect to some nodes).
15f218
+    message = stderr.join
15f218
+    if not message.include?(', use --force to override')
15f218
+      message += ', use --force to override'
15f218
+    end
15f218
+    return [400, message]
15f218
   end
15f218
 
15f218
   node_list.each {|node|
15f218
-- 
15f218
1.8.3.1
15f218