From f0edfcf68f349dd23720b2360150dd57ec5b9e46 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Fri, 5 Aug 2011 14:27:46 +0200
Subject: [PATCH] =?UTF-8?q?Remove=20iallocator's=20=E2=80=9Cmulti-evacuate?=
 =?UTF-8?q?=E2=80=9D=20mode?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It is no longer used and has been deprecated in 2.5.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 doc/iallocator.rst      | 29 ++++-------------------------
 lib/client/gnt_debug.py |  1 -
 lib/cmdlib.py           | 35 +----------------------------------
 lib/constants.py        |  2 --
 lib/opcodes.py          |  2 --
 5 files changed, 5 insertions(+), 64 deletions(-)

diff --git a/doc/iallocator.rst b/doc/iallocator.rst
index a81e981a1..26cc80858 100644
--- a/doc/iallocator.rst
+++ b/doc/iallocator.rst
@@ -190,15 +190,16 @@ In all cases, it includes:
 
   type
     the request type; this can be either ``allocate``, ``relocate``,
-    ``change-group``, ``node-evacuate`` or ``multi-evacuate``. The
+    ``change-group`` or ``node-evacuate``. The
     ``allocate`` request is used when a new instance needs to be placed
     on the cluster. The ``relocate`` request is used when an existing
     instance needs to be moved within its node group.
 
     The ``multi-evacuate`` protocol used to request that the script
     computes the optimal relocate solution for all secondary instances
-    of the given nodes. It is now deprecated and should no longer be
-    used.
+    of the given nodes. It is now deprecated and needs only be
+    implemented if backwards compatibility with Ganeti 2.4 and lower is
+    needed.
 
     The ``change-group`` request is used to relocate multiple instances
     across multiple node groups. ``node-evacuate`` evacuates instances
@@ -302,12 +303,6 @@ As for ``node-evacuate``, it needs the following request arguments:
     should be considered for relocating instances to; type
     *list of strings*
 
-Finally, in the case of multi-evacuate, there's one single request
-argument (in addition to ``type``):
-
-  evac_nodes
-    the names of the nodes to be evacuated; type *list of strings*
-
 Response message
 ~~~~~~~~~~~~~~~~
 
@@ -335,9 +330,6 @@ result
   serialized opcodes; see the :ref:`design document
   <multi-reloc-result>` for a detailed description
 
-  for multi-evacuation mode, this is a list of lists; each element of
-  the list is a list of instance name and the new secondary node
-
 .. note:: Current Ganeti version accepts either ``result`` or ``nodes``
    as a backwards-compatibility measure (older versions only supported
    ``nodes``)
@@ -505,19 +497,6 @@ Input message, reallocation::
     }
   }
 
-Input message, node evacuation::
-
-  {
-    "version": 2,
-    ...
-    "request": {
-      "type": "multi-evacuate",
-      "evac_nodes": [
-        "node2"
-      ],
-    }
-  }
-
 
 Response messages
 ~~~~~~~~~~~~~~~~~
diff --git a/lib/client/gnt_debug.py b/lib/client/gnt_debug.py
index 54037766a..ecb3fedf8 100644
--- a/lib/client/gnt_debug.py
+++ b/lib/client/gnt_debug.py
@@ -163,7 +163,6 @@ def TestAllocator(opts, args):
 
   op = opcodes.OpTestAllocator(mode=opts.mode,
                                name=args[0],
-                               evac_nodes=args,
                                instances=args,
                                memory=opts.memory,
                                disks=disks,
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index f5fb798df..7821e19c3 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -12759,7 +12759,6 @@ class IAllocator(object):
     self.hypervisor = None
     self.relocate_from = None
     self.name = None
-    self.evac_nodes = None
     self.instances = None
     self.evac_mode = None
     self.target_groups = []
@@ -13041,15 +13040,6 @@ class IAllocator(object):
       }
     return request
 
-  def _AddEvacuateNodes(self):
-    """Add evacuate nodes data to allocator structure.
-
-    """
-    request = {
-      "evac_nodes": self.evac_nodes
-      }
-    return request
-
   def _AddNodeEvacuate(self):
     """Get data for node-evacuate requests.
 
@@ -13130,9 +13120,6 @@ class IAllocator(object):
       (_AddRelocateInstance,
        [("name", ht.TString), ("relocate_from", _STRING_LIST)],
        ht.TList),
-    constants.IALLOCATOR_MODE_MEVAC:
-      (_AddEvacuateNodes, [("evac_nodes", _STRING_LIST)],
-       ht.TListOf(ht.TAnd(ht.TIsLength(2), _STRING_LIST))),
      constants.IALLOCATOR_MODE_NODE_EVAC:
       (_AddNodeEvacuate, [
         ("instances", _STRING_LIST),
@@ -13191,8 +13178,7 @@ class IAllocator(object):
                                (self._result_check, self.result),
                                errors.ECODE_INVAL)
 
-    if self.mode in (constants.IALLOCATOR_MODE_RELOC,
-                     constants.IALLOCATOR_MODE_MEVAC):
+    if self.mode == constants.IALLOCATOR_MODE_RELOC:
       node2group = dict((name, ndata["group"])
                         for (name, ndata) in self.in_data["nodes"].items())
 
@@ -13211,17 +13197,6 @@ class IAllocator(object):
                                    " differ from original groups (%s)" %
                                    (utils.CommaJoin(result_groups),
                                     utils.CommaJoin(request_groups)))
-      elif self.mode == constants.IALLOCATOR_MODE_MEVAC:
-        request_groups = fn(self.evac_nodes)
-        for (instance_name, secnode) in self.result:
-          result_groups = fn([secnode])
-          if result_groups != request_groups:
-            raise errors.OpExecError("Iallocator returned new secondary node"
-                                     " '%s' (group '%s') for instance '%s'"
-                                     " which is not in original group '%s'" %
-                                     (secnode, utils.CommaJoin(result_groups),
-                                      instance_name,
-                                      utils.CommaJoin(request_groups)))
       else:
         raise errors.ProgrammerError("Unhandled mode '%s'" % self.mode)
 
@@ -13307,10 +13282,6 @@ class LUTestAllocator(NoHooksLU):
       self.op.name = fname
       self.relocate_from = \
           list(self.cfg.GetInstanceInfo(fname).secondary_nodes)
-    elif self.op.mode == constants.IALLOCATOR_MODE_MEVAC:
-      if not hasattr(self.op, "evac_nodes"):
-        raise errors.OpPrereqError("Missing attribute 'evac_nodes' on"
-                                   " opcode input", errors.ECODE_INVAL)
     elif self.op.mode in (constants.IALLOCATOR_MODE_CHG_GROUP,
                           constants.IALLOCATOR_MODE_NODE_EVAC):
       if not self.op.instances:
@@ -13351,10 +13322,6 @@ class LUTestAllocator(NoHooksLU):
                        name=self.op.name,
                        relocate_from=list(self.relocate_from),
                        )
-    elif self.op.mode == constants.IALLOCATOR_MODE_MEVAC:
-      ial = IAllocator(self.cfg, self.rpc,
-                       mode=self.op.mode,
-                       evac_nodes=self.op.evac_nodes)
     elif self.op.mode == constants.IALLOCATOR_MODE_CHG_GROUP:
       ial = IAllocator(self.cfg, self.rpc,
                        mode=self.op.mode,
diff --git a/lib/constants.py b/lib/constants.py
index 5ab9c3b42..53d90478d 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -1025,13 +1025,11 @@ VALID_IALLOCATOR_DIRECTIONS = frozenset([
   ])
 IALLOCATOR_MODE_ALLOC = "allocate"
 IALLOCATOR_MODE_RELOC = "relocate"
-IALLOCATOR_MODE_MEVAC = "multi-evacuate"
 IALLOCATOR_MODE_CHG_GROUP = "change-group"
 IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
 VALID_IALLOCATOR_MODES = frozenset([
   IALLOCATOR_MODE_ALLOC,
   IALLOCATOR_MODE_RELOC,
-  IALLOCATOR_MODE_MEVAC,
   IALLOCATOR_MODE_CHG_GROUP,
   IALLOCATOR_MODE_NODE_EVAC,
   ])
diff --git a/lib/opcodes.py b/lib/opcodes.py
index da6b44ccb..7d9f4b384 100644
--- a/lib/opcodes.py
+++ b/lib/opcodes.py
@@ -1541,8 +1541,6 @@ class OpTestAllocator(OpCode):
     ("vcpus", None, ht.TOr(ht.TNone, ht.TPositiveInt), None),
     ("os", None, ht.TMaybeString, None),
     ("disk_template", None, ht.TMaybeString, None),
-    ("evac_nodes", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)),
-     None),
     ("instances", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)),
      None),
     ("evac_mode", None,
-- 
GitLab