cephfs: No-Op Protect 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 ProtectSnapshot
call should be treated as a no-op

Signed-off-by: Yug <yuggupta27@gmail.com>
(cherry picked from commit 43a4c100ec)
This commit is contained in:
Yug 2020-09-15 20:03:16 +05:30 committed by mergify[bot]
parent b32569bc47
commit 15463d8f52

View File

@ -25,6 +25,10 @@ import (
"github.com/golang/protobuf/ptypes/timestamp" "github.com/golang/protobuf/ptypes/timestamp"
) )
// autoProtect points to the snapshot auto-protect feature of
// the subvolume.
const autoProtect = "snapshot-autoprotect"
// cephfsSnapshot represents a CSI snapshot and its cluster information. // cephfsSnapshot represents a CSI snapshot and its cluster information.
type cephfsSnapshot struct { type cephfsSnapshot struct {
NamePrefix string NamePrefix string
@ -137,6 +141,11 @@ func getSnapshotInfo(ctx context.Context, volOptions *volumeOptions, cr *util.Cr
} }
func protectSnapshot(ctx context.Context, volOptions *volumeOptions, cr *util.Credentials, snapID, volID volumeID) error { func protectSnapshot(ctx context.Context, volOptions *volumeOptions, cr *util.Credentials, snapID, volID volumeID) error {
// If "snapshot-autoprotect" feature is present, The ProtectSnapshot
// call should be treated as a no-op.
if checkSubvolumeHasFeature(autoProtect, volOptions.Features) {
return nil
}
args := []string{ args := []string{
"fs", "fs",
"subvolume", "subvolume",