From 2d67c1b9a4f2d2ad6642f253fc3a25331c334894 Mon Sep 17 00:00:00 2001 From: jshen28 Date: Thu, 30 Sep 2021 02:33:48 +0800 Subject: Use ascii code for growpart (#1036) growpart not working well for environment using UTF-8 encoding. This patch forces growpart command to use C locale. Root issue likely: https://bugs.launchpad.net/ubuntu/+source/cloud-utils/+bug/1928167 --- cloudinit/config/cc_growpart.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cloudinit/config/cc_growpart.py b/cloudinit/config/cc_growpart.py index 9f5525a1..ce7ca78b 100644 --- a/cloudinit/config/cc_growpart.py +++ b/cloudinit/config/cc_growpart.py @@ -142,9 +142,11 @@ class ResizeGrowPart(object): return False def resize(self, diskdev, partnum, partdev): + myenv = os.environ.copy() + myenv['LANG'] = 'C' before = get_size(partdev) try: - subp.subp(["growpart", '--dry-run', diskdev, partnum]) + subp.subp(["growpart", '--dry-run', diskdev, partnum], env=myenv) except subp.ProcessExecutionError as e: if e.exit_code != 1: util.logexc(LOG, "Failed growpart --dry-run for (%s, %s)", @@ -153,7 +155,7 @@ class ResizeGrowPart(object): return (before, before) try: - subp.subp(["growpart", diskdev, partnum]) + subp.subp(["growpart", diskdev, partnum], env=myenv) except subp.ProcessExecutionError as e: util.logexc(LOG, "Failed: growpart %s %s", diskdev, partnum) raise ResizeFailedException(e) from e -- cgit v1.2.3