From 799d35991e28f1f96fb250b97c29ca3df62a39e3 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 10 Oct 2024 17:58:09 +0200 Subject: [PATCH] e2e: detect support for VolumeGroupSnapshot in librbd Signed-off-by: Niels de Vos --- e2e/rbd.go | 8 ++++++++ e2e/rbd_helper.go | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/e2e/rbd.go b/e2e/rbd.go index 22d9589c2844..33e9b8390152 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -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 { diff --git a/e2e/rbd_helper.go b/e2e/rbd_helper.go index b35e38a432c4..34a99ea09476 100644 --- a/e2e/rbd_helper.go +++ b/e2e/rbd_helper.go @@ -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