From 57f8ee0aa7457b559a3e1b45054e0bb344874d3a Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 4 Nov 2020 13:46:31 +0100 Subject: [PATCH] cephfs: make createSnapshot() a method of volumeOptions Signed-off-by: Niels de Vos --- internal/cephfs/clone.go | 2 +- internal/cephfs/controllerserver.go | 2 +- internal/cephfs/snapshot.go | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/cephfs/clone.go b/internal/cephfs/clone.go index 6d0b0abc5..3144f28e1 100644 --- a/internal/cephfs/clone.go +++ b/internal/cephfs/clone.go @@ -45,7 +45,7 @@ const ( func createCloneFromSubvolume(ctx context.Context, volID, cloneID volumeID, volOpt, parentvolOpt *volumeOptions, cr *util.Credentials) error { snapshotID := cloneID - err := createSnapshot(ctx, parentvolOpt, cr, snapshotID, volID) + err := parentvolOpt.createSnapshot(ctx, cr, snapshotID, volID) if err != nil { util.ErrorLog(ctx, "failed to create snapshot %s %v", snapshotID, err) return err diff --git a/internal/cephfs/controllerserver.go b/internal/cephfs/controllerserver.go index 629154423..4169f70ab 100644 --- a/internal/cephfs/controllerserver.go +++ b/internal/cephfs/controllerserver.go @@ -587,7 +587,7 @@ func doSnapshot(ctx context.Context, volOpt *volumeOptions, subvolumeName, snaps volID := volumeID(subvolumeName) snapID := volumeID(snapshotName) snap := snapshotInfo{} - err := createSnapshot(ctx, volOpt, cr, snapID, volID) + err := volOpt.createSnapshot(ctx, cr, snapID, volID) if err != nil { util.ErrorLog(ctx, "failed to create snapshot %s %v", snapID, err) return snap, err diff --git a/internal/cephfs/snapshot.go b/internal/cephfs/snapshot.go index 46cd71d05..6df9cad3b 100644 --- a/internal/cephfs/snapshot.go +++ b/internal/cephfs/snapshot.go @@ -45,18 +45,18 @@ type cephfsSnapshot struct { ReservedID string } -func createSnapshot(ctx context.Context, volOptions *volumeOptions, cr *util.Credentials, snapID, volID volumeID) error { +func (vo *volumeOptions) createSnapshot(ctx context.Context, cr *util.Credentials, snapID, volID volumeID) error { args := []string{ "fs", "subvolume", "snapshot", "create", - volOptions.FsName, + vo.FsName, string(volID), string(snapID), "--group_name", - volOptions.SubvolumeGroup, - "-m", volOptions.Monitors, + vo.SubvolumeGroup, + "-m", vo.Monitors, "-c", util.CephConfigPath, "-n", cephEntityClientPrefix + cr.ID, "--keyfile=" + cr.KeyFile, @@ -67,7 +67,7 @@ func createSnapshot(ctx context.Context, volOptions *volumeOptions, cr *util.Cre "ceph", args[:]...) if err != nil { - util.ErrorLog(ctx, "failed to create subvolume snapshot %s %s(%s) in fs %s", string(snapID), string(volID), err, volOptions.FsName) + util.ErrorLog(ctx, "failed to create subvolume snapshot %s %s(%s) in fs %s", string(snapID), string(volID), err, vo.FsName) return err } return nil