From 11a6f6c1dd908bd393590898327eedea8e9d63c8 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 20 Jul 2020 10:03:55 +0530 Subject: [PATCH] rbd: Support data-pool when cloning rbd image Added support to clone an image in data-pool during CreateVolume RPC call. updates #1188 Signed-off-by: Madhu Rajanna --- internal/rbd/rbd_util.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index a18c401c5..de32497a2 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -833,10 +833,22 @@ func (rv *rbdVolume) deleteSnapshot(ctx context.Context, pOpts *rbdSnapshot) err func (rv *rbdVolume) cloneRbdImageFromSnapshot(ctx context.Context, pSnapOpts *rbdSnapshot) error { image := rv.RbdImageName var err error - util.DebugLog(ctx, "rbd: clone %s %s using mon %s", pSnapOpts, image, rv.Monitors) + logMsg := "rbd: clone %s %s (features: %s) using mon %s" options := librbd.NewRbdImageOptions() defer options.Destroy() + + if rv.DataPool != "" { + logMsg += fmt.Sprintf(", data pool %s", rv.DataPool) + err = options.SetString(librbd.RbdImageOptionDataPool, rv.DataPool) + if err != nil { + return fmt.Errorf("failed to set data pool: %w", err) + } + } + + util.DebugLog(ctx, logMsg, + pSnapOpts, image, rv.imageFeatureSet.Names(), rv.Monitors) + if rv.imageFeatureSet != 0 { err = options.SetUint64(librbd.RbdImageOptionFeatures, uint64(rv.imageFeatureSet)) if err != nil {