From 0f51df99e8310e874a1aa648f808d97162e286a1 Mon Sep 17 00:00:00 2001 From: Yug Date: Thu, 10 Sep 2020 17:35:53 +0530 Subject: [PATCH] cephfs: validate if subvolume has snapshot-retention feature Add validateSnapshotRetention() to verify if subvolume has `snapshot-retention` feature. Signed-off-by: Yug (cherry picked from commit 59fc4aa00ff25cc0917f307408ee454d4b97419a) --- internal/cephfs/volume.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/cephfs/volume.go b/internal/cephfs/volume.go index 603adb515..ee3f55696 100644 --- a/internal/cephfs/volume.go +++ b/internal/cephfs/volume.go @@ -269,3 +269,16 @@ func purgeVolume(ctx context.Context, volID volumeID, cr *util.Credentials, volO return nil } + +// checkSubvolumeHasFeature verifies if the referred subvolume has +// the required feature. +func checkSubvolumeHasFeature(feature string, subVolFeatures []string) bool { + // The subvolume "features" are based on the internal version of the subvolume. + // Verify if subvolume supports the required feature. + for _, subvolFeature := range subVolFeatures { + if subvolFeature == feature { + return true + } + } + return false +}