From b775c337b3dcd519f903fdee4283f4bb2826d5d6 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 19 Aug 2009 10:00:08 +0200 Subject: [PATCH] repair-size: ensure child disks have sane sizes While this patch doesn't do a full match of on-disk size to config-size for child devices, it does a sanity check (for DRBD only) that the child size is not less than the DRBD size. While this would be a strange occurrence (failed growth and masterd crash or similar), it does prevent replace-disks from working. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/cmdlib.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 4d20e103e..a9b3bac26 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -1377,6 +1377,29 @@ class LURepairDiskSizes(NoHooksLU): self.wanted_instances = [self.cfg.GetInstanceInfo(name) for name in self.wanted_names] + def _EnsureChildSizes(self, disk): + """Ensure children of the disk have the needed disk size. + + This is valid mainly for DRBD8 and fixes an issue where the + children have smaller disk size. + + @param disk: an L{ganeti.objects.Disk} object + + """ + if disk.dev_type == constants.LD_DRBD8: + assert disk.children, "Empty children for DRBD8?" + fchild = disk.children[0] + mismatch = fchild.size < disk.size + if mismatch: + self.LogInfo("Child disk has size %d, parent %d, fixing", + fchild.size, disk.size) + fchild.size = disk.size + + # and we recurse on this child only, not on the metadev + return self._EnsureChildSizes(fchild) or mismatch + else: + return False + def Exec(self, feedback_fn): """Verify the size of cluster disks. @@ -1422,6 +1445,9 @@ class LURepairDiskSizes(NoHooksLU): disk.size = size self.cfg.Update(instance) changed.append((instance.name, idx, size)) + if self._EnsureChildSizes(disk): + self.cfg.Update(instance) + changed.append((instance.name, idx, disk.size)) return changed -- GitLab