Skip to content

Commit

Permalink
fix(growpart): Test fix for growpart race
Browse files Browse the repository at this point in the history
  • Loading branch information
holmanb committed Nov 21, 2023
1 parent be8ed18 commit 50428a3
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions cloudinit/config/cc_growpart.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,15 @@ def resize(self, diskdev, partnum, partdev):


def get_size(filename):
fd = os.open(filename, os.O_RDONLY)
fd = None
try:
fd = os.open(filename, os.O_RDONLY)
return os.lseek(fd, 0, os.SEEK_END)
except FileNotFoundError:
return None
finally:
os.close(fd)
if fd:
os.close(fd)


def device_part_info(devpath):
Expand Down Expand Up @@ -571,7 +575,7 @@ def resize_devices(resizer, devices):
continue

try:
(old, new) = resizer.resize(disk, ptnum, blockdev)
old, new = resizer.resize(disk, ptnum, blockdev)
if old == new:
info.append(
(
Expand All @@ -580,6 +584,15 @@ def resize_devices(resizer, devices):
"no change necessary (%s, %s)" % (disk, ptnum),
)
)
elif new is None:
info.append(
(
devent,
RESIZE.CHANGED,
"changed (%s, %s) from %s, new size is unknown"
% (disk, ptnum, old),
)
)
else:
info.append(
(
Expand Down

0 comments on commit 50428a3

Please sign in to comment.