← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~smoser/cloud-init:bug/1684869-fix-by-partuuid into cloud-init:master

 

Scott Moser has proposed merging ~smoser/cloud-init:bug/1684869-fix-by-partuuid into cloud-init:master.

Commit message:
Fix growpart for some cases when booted with root=PARTUUID.

Growing the root partition would fail in either of two cases:
 a.) if the device /dev/root existed
 b.) the kernel command line had upper case letters in PARTUUID=<value>
     the kernel will accept upper case partuuid, but udev creates
     links with lower case. In that scenario, we need to adjust to
     a /dev/disk/by-<partuuid|uuid> with lower case.

The fix here addresses that, and also fixes uuid similarly for the
lowercase issue.

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/322875
-- 
Your team cloud init development team is requested to review the proposed merge of ~smoser/cloud-init:bug/1684869-fix-by-partuuid into cloud-init:master.
diff --git a/cloudinit/config/cc_growpart.py b/cloudinit/config/cc_growpart.py
index 089693e..d2bc6e6 100644
--- a/cloudinit/config/cc_growpart.py
+++ b/cloudinit/config/cc_growpart.py
@@ -252,9 +252,13 @@ def devent2dev(devent):
     container = util.is_container()
 
     # Ensure the path is a block device.
-    if (dev == "/dev/root" and not os.path.exists(dev) and not container):
+    if (dev == "/dev/root" and not container):
         dev = util.rootdev_from_cmdline(util.get_cmdline())
         if dev is None:
+            if os.path.exists(dev):
+                # if /dev/root exists, but we failed to convert
+                # that to a "real" /dev/ path device, then return it.
+                return dev
             raise ValueError("Unable to find device '/dev/root'")
     return dev
 
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 6940850..070f3f2 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -2404,9 +2404,10 @@ def rootdev_from_cmdline(cmdline):
     if found.startswith("LABEL="):
         return "/dev/disk/by-label/" + found[len("LABEL="):]
     if found.startswith("UUID="):
-        return "/dev/disk/by-uuid/" + found[len("UUID="):]
+        return "/dev/disk/by-uuid/" + found[len("UUID="):].lower()
     if found.startswith("PARTUUID="):
-        disks_path = "/dev/disk/by-partuuid/" + found[len("PARTUUID="):]
+        disks_path = ("/dev/disk/by-partuuid/" +
+                      found[len("PARTUUID="):].lower())
         if os.path.exists(disks_path):
             return disks_path
         results = find_devs_with(found)

References