Skip to content

Commit

Permalink
Added support for PV grow
Browse files Browse the repository at this point in the history
Storage role requires support for a case when PV has to be resized to
fill all available space when its device's size changes (usually on VM).

A new flag 'grow_to_fill' was added, which marks the device for size
expansion (all available space it taken).
Proper size is determined by LVM, avoiding inaccurate size
calculations in blivet.
  • Loading branch information
japokorn committed Apr 25, 2024
1 parent a91c775 commit d3f2873
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions blivet/formats/lvmpv.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def __init__(self, **kwargs):

self.inconsistent_vg = False

# when set to True, blivet will try to resize the PV to fill all available space
self.grow_to_fill = False

def __repr__(self):
s = DeviceFormat.__repr__(self)
s += (" vg_name = %(vg_name)s vg_uuid = %(vg_uuid)s"
Expand Down
7 changes: 6 additions & 1 deletion blivet/tasks/pvtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ def __init__(self, a_pv):
def do_task(self): # pylint: disable=arguments-differ
""" Resizes the LVMPV format. """
try:
blockdev.lvm.pvresize(self.pv.device, self.pv.target_size.convert_to(self.unit))
if self.pv.grow_to_fill:
# resize PV to fill all available space on device by omitting
# the size parameter
blockdev.lvm.pvresize(self.pv.device)
else:
blockdev.lvm.pvresize(self.pv.device, self.pv.target_size.convert_to(self.unit))
except blockdev.LVMError as e:
raise PhysicalVolumeError(e)

0 comments on commit d3f2873

Please sign in to comment.