Burnin OpGrowDisk
authorIustin Pop <iustin@google.com>
Tue, 14 Oct 2008 16:22:14 +0000 (16:22 +0000)
committerIustin Pop <iustin@google.com>
Tue, 14 Oct 2008 16:22:14 +0000 (16:22 +0000)
With this patch both the os and the swap disk are grown during
burnin. You can pass an increase size of 0 to skip this operation.

and:

burnin: don't try to grow diskless instances

    When burnin is run on a diskless instance, it fails when trying
    GrowDisk, because a non-existant disk cannot be grown. This patch
    disables the test for that disk template.

This is a forward-port of revisions 1181 and 1606 on the 1.2 branch.

Original author: ultrotter
Reviewed-by: ultrotter

tools/burnin

index 69236d5..ace2233 100755 (executable)
@@ -129,8 +129,12 @@ class Burner(object):
                       metavar="<OS>")
     parser.add_option("--os-size", dest="os_size", help="Disk size",
                       default=4 * 1024, type="unit", metavar="<size>")
+    parser.add_option("--os-growth", dest="sda_growth", help="Disk growth",
+                      default=1024, type="unit", metavar="<size>")
     parser.add_option("--swap-size", dest="swap_size", help="Swap size",
                       default=4 * 1024, type="unit", metavar="<size>")
+    parser.add_option("--swap-growth", dest="sdb_growth", help="Swap growth",
+                      default=1024, type="unit", metavar="<size>")
     parser.add_option("--mem-size", dest="mem_size", help="Memory size",
                       default=128, type="unit", metavar="<size>")
     parser.add_option("-v", "--verbose",
@@ -277,6 +281,17 @@ class Burner(object):
     if self.opts.parallel:
       self.ExecJobSet(jobset)
 
+  def GrowDisks(self):
+    """Grow both the os and the swap disks by the requested amount, if any."""
+    for instance in self.instances:
+      for disk in ['sda', 'sdb']:
+        growth = getattr(self.opts, '%s_growth' % disk)
+        if growth > 0:
+          op = opcodes.OpGrowDisk(instance_name=instance, disk=disk,
+                                  amount=growth)
+          Log("- Increase %s's %s disk by %s MB" % (instance, disk, growth))
+          self.ExecOp(op)
+
   def ReplaceDisks1D8(self):
     """Replace disks on primary and secondary for drbd8."""
     for instance in self.instances:
@@ -454,6 +469,9 @@ class Burner(object):
           opts.disk_template in constants.DTS_NET_MIRROR) :
         self.ReplaceDisks2()
 
+      if opts.disk_template != constants.DT_DISKLESS:
+        self.GrowDisks()
+
       if opts.do_failover and opts.disk_template in constants.DTS_NET_MIRROR:
         self.Failover()