Skip to content

Block device support fixes#89

Merged
bmr-cymru merged 57 commits intomainfrom
bmr-add_blockdev_support
Dec 11, 2024
Merged

Block device support fixes#89
bmr-cymru merged 57 commits intomainfrom
bmr-add_blockdev_support

Conversation

@bmr-cymru
Copy link
Copy Markdown
Contributor

  • snapm: fix lints in snapm.manager (temporary)
  • snapm: check that source paths are either a mount point or block device
  • lvm2: accept paths in /dev/vg/lv format in vg_lv_from_device_path()

Supplements #88

@bmr-cymru bmr-cymru force-pushed the bmr-add_blockdev_support branch from 22e4875 to d7826ba Compare November 12, 2024 20:15
@packit-as-a-service
Copy link
Copy Markdown

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/snapshotmanager-snapm-89
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

@bmr-cymru
Copy link
Copy Markdown
Contributor Author

The python-basic-tests job is stuck in apt-get, possibly an infrastructure issue? I'll try manually restarting it.

@bmr-cymru bmr-cymru force-pushed the bmr-add_blockdev_support branch from d7826ba to d1606f8 Compare November 20, 2024 14:55
bmr-cymru and others added 5 commits November 25, 2024 13:30
draft commit just for sharing ideas
The vg_lv_from_device_path() expects a path in /dev/mapper/vg-lv form
and uses the 'dmsetup splitname' command to return a (vg, lv) tuple.

Extend this to also support LV paths in the /dev/vg/lv symlink form by
replacing 'dmsetup splitname' with 'lvs -ovg_name,lv_name $device'.
@bmr-cymru bmr-cymru force-pushed the bmr-add_blockdev_support branch from d1606f8 to 700de34 Compare November 25, 2024 13:30
@bmr-cymru bmr-cymru self-assigned this Nov 25, 2024
@bmr-cymru bmr-cymru linked an issue Nov 25, 2024 that may be closed by this pull request
Include the CalledProcessError.stderr text in the SnapmError raised
when a callout fails.
For consistency between block device and mount point sources always
include the '/dev' prefix when returning a value from
Plugin.origin_from_mount_point().
@bmr-cymru bmr-cymru force-pushed the bmr-add_blockdev_support branch 3 times, most recently from 9e36feb to 97967dc Compare December 1, 2024 19:15
The %USED SizePolicy allows a snapshot to be sized based on the space
used by the filesystem present on the device: do not allow %USED to
be specified for unmounted block device snapshots.
Return the special value -1 if mount_point_space_used() is called for a
non-mount path.
This makes the size map handling consistent for block device and
mount point snapshot sources.
Reflect that the target can be either a mount point or block device path
in the argument name and docstring comments.
Add properties to reflect the combined list of block device and
mount point sources for a Snapshot or SnapshotSet.
Add a method to look up a member of a SnapshotSet by source.
Disable too-many-branches and too-many-locals.
Generalise is_stratis_device() to accept either /dev/mapper/... or
/dev/stratis/$POOL/$FS symlinks when detecting Stratis devices.
Only display the separate MountPoints and Devices fields if both
have at least one entry (i.e. the SnapshotSet is composed of both
mount point and block device sources):

  # snapm snapset create bdev0 /var /dev/fedora/data / /home
  SnapsetName:      bdev0
  Sources:          /var, /dev/fedora/data, /, /home
    MountPoints:    /var, /, /home
    Devices:        /dev/fedora/data
  NrSnapshots:      4
  Time:             2024-12-03 15:20:55
  UUID:             a6df0b66-b4fc-5bd3-93be-af1fad0b64b9
  Status:           Inactive
  Autoactivate:     no
  Bootable:         no

Vs:

  # snapm snapset create upgrade / /var
  SnapsetName:      upgrade
  Sources:          /, /var
  NrSnapshots:      2
  Time:             2024-12-03 15:21:00
  UUID:             77d0c2af-7017-5c4a-b8a4-502f8024e502
  Status:           Active
  Autoactivate:     yes
  Bootable:         no
Don't allow the same volume to be added to a snapshot set twice as both
a block device and a mount point source:

   # snapm snapset create bdev0 /dev/fedora/var /var
   ERROR - Error creating snapshot set member bdev0: lvcreate failed with: Logical Volume "var-snapset_bdev0_1733079682_-var" already exists in volume group "fedora"
   ERROR - Command failed: Could not create all snapshots for set bdev0

Vs:

  # snapm snapset create bdev0 /var /dev/fedora/var / /home
  ERROR - Command failed: Duplicate snapshot source /dev/fedora/var already added to bdev0 as /var
@bmr-cymru bmr-cymru force-pushed the bmr-add_blockdev_support branch from 97967dc to 65ad29a Compare December 3, 2024 19:29
Snapshot manager currently allows snapshots-of-snapshots:

  # for M in "" boot dev home proc run sys sys/fs/selinux var; do mount --bind /$M /mnt/$M; done
  # mount /dev/stratis/p1/fs1-snapset_testset0_1733504066_-opt /mnt/opt
  # mount /dev/stratis/p1/fs2-snapset_testset0_1733504066_-srv /mnt/srv
  # chroot /mnt/
  # snapm snapset list
  SnapsetName  Time                 NrSnapshots Status  Sources
  testset0     2024-12-06 16:54:26            2 Active  /opt, /srv
  # snapm snapset create recurs /opt /srv
  SnapsetName:      recurs
  Sources:          /opt, /srv
  NrSnapshots:      2
  Time:             2024-12-06 16:55:51
  UUID:             23ccb96e-1e00-5ffb-91e9-d0c84ea6027b
  Status:           Active
  Autoactivate:     yes
  Bootable:         no
  # snapm snapset show recurs --members
  SnapsetName:      recurs
  Sources:          /opt, /srv
  NrSnapshots:      2
  Time:             2024-12-06 16:55:51
  UUID:             23ccb96e-1e00-5ffb-91e9-d0c84ea6027b
  Status:           Active
  Autoactivate:     yes
  Bootable:         no
  Snapshots:
      Name:           p1/fs1-snapset_testset0_1733504066_-opt-snapset_recurs_1733504151_-opt
      SnapsetName:    recurs
      Origin:         /dev/stratis/p1/fs1-snapset_testset0_1733504066_-opt
      Time:           2024-12-06 16:55:51
      Source:         /opt
      MountPoint:     /opt
      Provider:       stratis
      UUID:           65057e3a-1268-58b9-be76-12feaa1d421c
      Status:         Active
      Size:           1.0GiB
      Free:           3.1GiB
      Autoactivate:   yes
      DevicePath:     /dev/stratis/p1/fs1-snapset_testset0_1733504066_-opt-snapset_recurs_1733504151_-opt
      Pool:           p1
      Filesystem:     fs1-snapset_testset0_1733504066_-opt-snapset_recurs_1733504151_-opt

      Name:           p1/fs2-snapset_testset0_1733504066_-srv-snapset_recurs_1733504151_-srv
      SnapsetName:    recurs
      Origin:         /dev/stratis/p1/fs2-snapset_testset0_1733504066_-srv
      Time:           2024-12-06 16:55:51
      Source:         /srv
      MountPoint:     /srv
      Provider:       stratis
      UUID:           c3f75665-e152-5749-8bb2-deccce0d9716
      Status:         Active
      Size:           2.0GiB
      Free:           3.1GiB
      Autoactivate:   yes
      DevicePath:     /dev/stratis/p1/fs2-snapset_testset0_1733504066_-srv-snapset_recurs_1733504151_-srv
      Pool:           p1
      Filesystem:     fs2-snapset_testset0_1733504066_-srv-snapset_recurs_1733504151_-srv

This works for the most part but there are a few problems with the
current behaviour:

  * Snapshot device names grow to unmanageable lengths (esp for depth >
    1).
  * Merge operations that affect a chain of snapshots may require
    rewriting the origin of dependent snapshot sets.
  * Some providers (lvm2thin) currently erase origin links when any
    snapshot within a series or chain is merged, orphaning any remaining
    snapshots of the same origin.
  * lvm2cow cannot support recursive snapshots due to the limitations of
    the dm-snapshot target.

These are solvable but require changes in other components and an
extension to the snapm naming format so for now prevent users from
creating recursive snapshot sets:

  # snapm snapset create recurs /opt /srv
  ERROR - Command failed: Snapshots of snapshots are not supported: /opt corresponds to snapshot device /dev/stratis/p1/fs1-snapset_testset0_1733504066_-opt
@bmr-cymru bmr-cymru force-pushed the bmr-add_blockdev_support branch from 915cb48 to b1f4943 Compare December 6, 2024 17:51
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.

consider supporting block devices that are not mounted?

2 participants