From 6a6495887680944bb7e45560f3072c8ba4831754 Mon Sep 17 00:00:00 2001 From: Yug Date: Wed, 16 Sep 2020 19:15:28 +0530 Subject: [PATCH] cephfs: No-Op Unprotect call if "snapshot-autoprotect" feature present The subvolume features consists the list of features, which if includes "snapshot-autoprotect", result in query based approach to detecting the need for protect/unprotect. If "snapshot-autoprotect" feature is present, The UnprotectSnapshot call should be treated as a no-op Signed-off-by: Yug (cherry picked from commit 9e959c45a388c0d4bc3edac24a35d89da5b0a453) --- internal/cephfs/snapshot.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/cephfs/snapshot.go b/internal/cephfs/snapshot.go index a20b702eb..de860587d 100644 --- a/internal/cephfs/snapshot.go +++ b/internal/cephfs/snapshot.go @@ -27,7 +27,9 @@ import ( // autoProtect points to the snapshot auto-protect feature of // the subvolume. -const autoProtect = "snapshot-autoprotect" +const ( + autoProtect = "snapshot-autoprotect" +) // cephfsSnapshot represents a CSI snapshot and its cluster information. type cephfsSnapshot struct { @@ -177,6 +179,11 @@ func protectSnapshot(ctx context.Context, volOptions *volumeOptions, cr *util.Cr } func unprotectSnapshot(ctx context.Context, volOptions *volumeOptions, cr *util.Credentials, snapID, volID volumeID) error { + // If "snapshot-autoprotect" feature is present, The UnprotectSnapshot + // call should be treated as a no-op. + if checkSubvolumeHasFeature(autoProtect, volOptions.Features) { + return nil + } args := []string{ "fs", "subvolume",