Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor LVM LV name generation and extract unique name generator into helper (COMPOSER-2355) #1003

Merged
merged 3 commits into from
Nov 1, 2024

Conversation

achilleas-k
Copy link
Member

@achilleas-k achilleas-k commented Oct 31, 2024

This is part of #926 which I'm slowly splitting into smaller, bite-sized PRs.


disk: refactor LVM Logical Volume name generation

The VolumeGroup.CreateLogicalVolume() function assumed that the given
name was a mountpoint and would automatically escape it, append 'lv',
and append numbers in case of collisions. This made it impossible to
use the helper function for LV creation with desired names.

Refactor the function and modify all the calls so that now it uses the
provided name without validating, escaping, or checking for collisions,
and generates a name from the payload's mountpoint when one is not
provided.

The CreateMountpoint() function's functionality is not affected.


disk: helper function for generating unique names

The new genUniqueString() function follows the logic used when
generating logical volume names, which was based on the same
functionality in blivet.
It will be used to generate unique logical volume names, labels, and
btrfs volume names.


disk: replace the lvm name generation with genUniqueString()

Replace the heart of the lvm name generator with the new function.
Update the vg.CreateMountpoint() test, because the old implementation
was off by one and would fail when '99' was available.


The VolumeGroup.CreateLogicalVolume() function assumed that the given
name was a mountpoint and would automatically escape it, append 'lv',
and append numbers in case of collisions.  This made it impossible to
use the helper function for LV creation with desired names.

Refactor the function and modify all the calls so that now it uses the
provided name without validating, escaping, or checking for collisions,
and generates a name from the payload's mountpoint when one is not
provided.

The CreateMountpoint() function's functionality is not affected.
The new genUniqueString() function follows the logic used when
generating logical volume names, which was based on the same
functionality in blivet.
It will be used to generate unique logical volume names, labels, and
btrfs volume names.
Replace the heart of the lvm name generator with the new function.
Update the vg.CreateMountpoint() test, because the old implementation
was off by one and would fail when '99' was available.
Copy link
Member

@ondrejbudai ondrejbudai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! ❤️

@ondrejbudai ondrejbudai added this pull request to the merge queue Nov 1, 2024
Merged via the queue into osbuild:main with commit d6365bd Nov 1, 2024
15 of 19 checks passed
@achilleas-k achilleas-k deleted the disk/unique-names branch November 1, 2024 15:45
@achilleas-k achilleas-k changed the title Refactor LVM LV name generation and extract unique name generator into helper Refactor LVM LV name generation and extract unique name generator into helper (COMPOSER-2355) Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants