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

feat: rename template to snapshot and add initial files for classic LVM snapshot support #2

Merged
merged 10 commits into from
Jan 13, 2024

Conversation

trgill
Copy link
Collaborator

@trgill trgill commented Nov 16, 2023

Enhancement:

Adding initial files for snapshot role. Currently supports only LVM classic (thick) snapshots.

Reason:

A role to support simple automated snapshot generation for LVM. Future support for LVM Thin, Stratis, BTRFS etc to be considered.

Result:

Basic support for creating added

Issue Tracker Tickets (Jira or BZ if any):
[RHELBU-1993]

@trgill trgill force-pushed the rename_template branch 2 times, most recently from 7dbaedc to e1a4406 Compare December 4, 2023 16:05
@trgill trgill changed the title feat : rename template to snapshot and add initial files for classic LVM snapshot support feat: rename template to snapshot and add initial files for classic LVM snapshot support Dec 5, 2023
@trgill trgill force-pushed the rename_template branch 5 times, most recently from c1f7a4e to 2d3181d Compare December 15, 2023 16:01
@trgill trgill force-pushed the rename_template branch 5 times, most recently from 87238d3 to c34c167 Compare January 12, 2024 00:58
@richm
Copy link
Contributor

richm commented Jan 12, 2024

[citest]

"{0:d} is not a positive integer".format(value)
)
except ValueError as error:
raise Exception("{0:04x} is not an integer".format(value)) from error
Copy link
Contributor

Choose a reason for hiding this comment

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

I've never seen this before - raise ... from ex - but python 2 on EL7 does not like it

Copy link
Contributor

Choose a reason for hiding this comment

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

or - if it is valid for python3, and you want the script to only work with python3, then we'll need to have the role install python3 on EL7 systems

@richm
Copy link
Contributor

richm commented Jan 12, 2024

Just a couple of changes to snapshot.py to make it work with python2 on el7.
Additionally, you'll need to create vars/RedHat_7.yml and vars/CentOS_7.yml with the following contents:

---
__snapshot_python: /usr/bin/python

With these changes, all of the EL7 tests pass

@trgill trgill force-pushed the rename_template branch 2 times, most recently from 302db46 to 56881cb Compare January 12, 2024 22:00
trgill and others added 9 commits January 12, 2024 17:28
The script is implemented as a command line.  The following commands are
supported:

positional arguments:
  {snapshot,check,clean}
                        Available operations
    snapshot            Snapshot given VG/LVs
    check               Check space for given VG/LV
    clean               Cleanup snapshots

The script supports the following parameters:

options for snapshot:
  -h, --help            show this help message and exit
  -a, --all             snapshot all VGs and LVs
  -vg VOLUME_GROUP, --volumegroup VOLUME_GROUP
                        volume group to snapshot
  -lv LOGICAL_VOLUME, --logicalvolume LOGICAL_VOLUME
                        logical volume to snapshot
  -r REQUIRED_SPACE, --requiredspace REQUIRED_SPACE
                        percent of required space in the volume group to be reserved for snapshot
  -s SUFFIX, --suffix SUFFIX
                        suffix to add to volume name for snapshot
  -p PREFIX, --prefix PREFIX
                        prefix to add to volume name for snapshot

options for check:

  -h, --help            show this help message and exit
  -a, --all             check all VGs and LVs
  -v, --verify          verify VGs and LVs have snapshots
  -vg VOLUME_GROUP, --volumegroup VOLUME_GROUP
                        volume group to check
  -lv LOGICAL_VOLUME, --logicalvolume LOGICAL_VOLUME
                        logical volume to check
  -r REQUIRED_SPACE, --requiredspace REQUIRED_SPACE
                        percent of required space in the volume group to be reserved for check
  -s SUFFIX, --suffix SUFFIX
                        suffix to add to volume name for check - will verify no name conflicts
  -p PREFIX, --prefix PREFIX
                        prefix to add to volume name for check - will verify no name conflicts

options for clean:

  -h, --help            show this help message and exit
  -a, --all             clean all VGs and LVs
  -v, --verify          verify clean completed for VGs and LVs
  -vg VOLUME_GROUP, --volumegroup VOLUME_GROUP
                        volume group to cleanup/remove
  -lv LOGICAL_VOLUME, --logicalvolume LOGICAL_VOLUME
                        logical volume to cleanup/remove
  -s SUFFIX, --suffix SUFFIX
                        suffix to add to volume name for cleanup/remove
  -p PREFIX, --prefix PREFIX
                        prefix to add to volume name for cleanup/remove

Signed-off-by: Todd Gill <[email protected]>
Co-authored-by: Richard Megginson <[email protected]>
Signed-off-by: Todd Gill <[email protected]>
Co-authored-by: Richard Megginson <[email protected]>
Signed-off-by: Todd Gill <[email protected]>
Co-authored-by: Sergei Petrosian <[email protected]>
Co-authored-by: Richard Megginson <[email protected]>
Each .yml file maps to a command supported by the snapshot CLI.

Signed-off-by: Todd Gill <[email protected]>
Co-authored-by: Richard Megginson <[email protected]>
Future testing to be added with preallocated LVM VGs/LVs for testing
different setups.

Signed-off-by: Todd Gill <[email protected]>
Change from template to snapshot.

Signed-off-by: Todd Gill <[email protected]>
for reuse

The qemu tests create a VM with scratch block devices to be used to
create VGs/LVs to be used as the soruce for testing snapshots.

The find_unused_disk function returns a list of disk that have
no contents inside the VM.

Signed-off-by: Todd Gill <[email protected]>
copied from the storage role

Signed-off-by: Todd Gill <[email protected]>
@richm
Copy link
Contributor

richm commented Jan 12, 2024

[citest]

@richm
Copy link
Contributor

richm commented Jan 12, 2024

Well, the el7 tests pass locally for me :-(
Investigating

@richm
Copy link
Contributor

richm commented Jan 13, 2024

Well, the el7 tests pass locally for me :-( Investigating

Looks like an issue with the test framework.

@richm richm merged commit abda4be into linux-system-roles:main Jan 13, 2024
8 of 9 checks passed
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.

3 participants