Skip to content

Commit

Permalink
e2e: detect support for VolumeGroupSnapshot in librbd
Browse files Browse the repository at this point in the history
Signed-off-by: Niels de Vos <ndevos@ibm.com>
  • Loading branch information
nixpanic committed Oct 29, 2024
1 parent e460225 commit e0e5978
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions e2e/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4746,6 +4746,14 @@ var _ = Describe("RBD", func() {
})

By("test volumeGroupSnapshot", func() {
supported, err := librbdSupportsVolumeGroupSnapshot(f)
if err != nil {
framework.Failf("failed to check for VolumeGroupSnapshot support: %v", err)
}
if !supported {
Skip("librbd does not support required VolumeGroupSnapshot function(s)")
}

scName := "csi-rbd-sc"
snapshotter, err := newRBDVolumeGroupSnapshot(f, f.UniqueName, scName, false, deployTimeout, 3)
if err != nil {
Expand Down
22 changes: 22 additions & 0 deletions e2e/rbd_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,28 @@ func validateEncryptedFilesystem(f *framework.Framework, rbdImageSpec, pvName, a
return nil
}

// librbdSupportsVolumeGroupSnapshot checks for the rbd_group_snap_get_info in
// librbd.so.* in a ceph-csi container. If this function is available,
// VolumeGroupSnapshot support is available.
func librbdSupportsVolumeGroupSnapshot(f *framework.Framework) (bool, error) {
selector, err := getDaemonSetLabelSelector(f, cephCSINamespace, rbdDaemonsetName)
if err != nil {
return false, fmt.Errorf("failed to get labels: %w", err)
}
opt := metav1.ListOptions{
LabelSelector: selector,
}

// run a shell command (to expand the * in the filename), return 0 on stdout when successful
cmd := "sh -c 'grep -q rbd_group_snap_get_info /lib64/librbd.so.*; echo $?'"
stdout, _, err := execCommandInContainer(f, cmd, cephCSINamespace, "csi-rbdplugin", &opt)
if err != nil {
return false, fmt.Errorf("error checking for rbd_group_snap_get_info in /lib64/librbd.so.*: %w", err)
}

return strings.TrimSpace(stdout) == "0", nil
}

func listRBDImages(f *framework.Framework, pool string) ([]string, error) {
var imgInfos []string

Expand Down

0 comments on commit e0e5978

Please sign in to comment.