Verify: make skipping checks possible
authorGuido Trotter <ultrotter@google.com>
Thu, 10 Apr 2008 16:48:26 +0000 (16:48 +0000)
committerGuido Trotter <ultrotter@google.com>
Thu, 10 Apr 2008 16:48:26 +0000 (16:48 +0000)
Add a general way to skip some checks at cluster-verify time and make the N+1
memory redundancy check optional.

Reviewed-by: iustinp

lib/cmdlib.py
lib/constants.py
lib/opcodes.py
scripts/gnt-cluster

index 14ac892..6bfc941 100644 (file)
@@ -658,7 +658,7 @@ class LUVerifyCluster(NoHooksLU):
   """Verifies the cluster status.
 
   """
-  _OP_REQP = []
+  _OP_REQP = ["skip_checks"]
 
   def _VerifyNode(self, node, file_list, local_cksum, vglist, node_result,
                   remote_version, feedback_fn):
@@ -831,10 +831,13 @@ class LUVerifyCluster(NoHooksLU):
   def CheckPrereq(self):
     """Check prerequisites.
 
-    This has no prerequisites.
+    Transform the list of checks we're going to skip into a set and check that
+    all its members are valid.
 
     """
-    pass
+    self.skip_set = frozenset(self.op.skip_checks)
+    if not constants.VERIFY_OPTIONAL_CHECKS.issuperset(self.skip_set):
+      raise errors.OpPrereqError("Invalid checks to be skipped specified")
 
   def Exec(self, feedback_fn):
     """Verify integrity of cluster, performing various test on nodes.
@@ -983,9 +986,10 @@ class LUVerifyCluster(NoHooksLU):
                                          feedback_fn)
     bad = bad or result
 
-    feedback_fn("* Verifying N+1 Memory redundancy")
-    result = self._VerifyNPlusOneMemory(node_info, instance_cfg, feedback_fn)
-    bad = bad or result
+    if constants.VERIFY_NPLUSONE_MEM not in self.skip_set:
+      feedback_fn("* Verifying N+1 Memory redundancy")
+      result = self._VerifyNPlusOneMemory(node_info, instance_cfg, feedback_fn)
+      bad = bad or result
 
     feedback_fn("* Other Notes")
     if i_non_redundant:
index 49661b5..249c9ca 100644 (file)
@@ -168,3 +168,8 @@ ALF_DIR_IN = "in"
 ALF_DIR_OUT = "out"
 ALF_MODE_ALLOC = "allocate"
 ALF_MODE_RELOC = "relocate"
+
+# Cluster Verify steps
+VERIFY_NPLUSONE_MEM = 'nplusone_mem'
+VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
+
index 8d86232..7ff2a36 100644 (file)
@@ -83,7 +83,7 @@ class OpRunClusterCommand(OpCode):
 class OpVerifyCluster(OpCode):
   """Verify the cluster state."""
   OP_ID = "OP_CLUSTER_VERIFY"
-  __slots__ = []
+  __slots__ = ["skip_checks"]
 
 
 class OpVerifyDisks(OpCode):
index 492ebee..9b8b4ec 100755 (executable)
@@ -178,7 +178,10 @@ def VerifyCluster(opts, args):
     opts - class with options as members
 
   """
-  op = opcodes.OpVerifyCluster()
+  skip_checks=[]
+  if opts.skip_nplusone_mem:
+    skip_checks.append(constants.VERIFY_NPLUSONE_MEM)
+  op = opcodes.OpVerifyCluster(skip_checks=skip_checks)
   result = SubmitOpCode(op)
   return result
 
@@ -328,7 +331,12 @@ commands = {
   'rename': (RenameCluster, ARGS_ONE, [DEBUG_OPT, FORCE_OPT],
                "<new_name>",
                "Renames the cluster"),
-  'verify': (VerifyCluster, ARGS_NONE, [DEBUG_OPT],
+  'verify': (VerifyCluster, ARGS_NONE, [DEBUG_OPT,
+             make_option("--no-nplus1-mem", dest="skip_nplusone_mem",
+                         help="Skip N+1 memory redundancy tests",
+                         action="store_true",
+                         default=False,),
+             ],
              "", "Does a check on the cluster configuration"),
   'verify-disks': (VerifyDisks, ARGS_NONE, [DEBUG_OPT],
                    "", "Does a check on the cluster disk status"),