From eae9bbff0f5a36796b3e1245b7f16582a3e5dc49 Mon Sep 17 00:00:00 2001 From: Rakshith R Date: Tue, 16 Nov 2021 16:06:18 +0530 Subject: [PATCH] rbd: add function (cc *ClusterConnection) GetTaskAdmin() This function returns new go-ceph TaskAdmin to add tasks on rbd volumes. Signed-off-by: Rakshith R --- internal/rbd/rbd_util.go | 6 ++---- internal/util/connection.go | 10 ++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index e8ccb88dce03..74c1f049bea2 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -669,12 +669,11 @@ func (rv *rbdVolume) deleteImage(ctx context.Context) error { func (rv *rbdVolume) trashRemoveImage(ctx context.Context) error { // attempt to use Ceph manager based deletion support if available - ra, err := rv.conn.GetRBDAdmin() + ta, err := rv.conn.GetTaskAdmin() if err != nil { return err } - ta := ra.Task() _, err = ta.AddTrashRemove(admin.NewImageSpec(rv.Pool, rv.RadosNamespace, rv.ImageID)) rbdCephMgrSupported := isCephMgrSupported(ctx, rv.ClusterID, err) if rbdCephMgrSupported && err != nil { @@ -815,12 +814,11 @@ func (rv *rbdVolume) flattenRbdImage( return nil } - ra, err := rv.conn.GetRBDAdmin() + ta, err := rv.conn.GetTaskAdmin() if err != nil { return err } - ta := ra.Task() _, err = ta.AddFlatten(admin.NewImageSpec(rv.Pool, rv.RadosNamespace, rv.RbdImageName)) rbdCephMgrSupported := isCephMgrSupported(ctx, rv.ClusterID, err) if rbdCephMgrSupported { diff --git a/internal/util/connection.go b/internal/util/connection.go index 9625d4e30987..fcd0d2cede9d 100644 --- a/internal/util/connection.go +++ b/internal/util/connection.go @@ -123,6 +123,16 @@ func (cc *ClusterConnection) GetRBDAdmin() (*ra.RBDAdmin, error) { return ra.NewFromConn(cc.conn), nil } +// GetTaskAdmin returns TaskAdmin to add tasks on rbd volumes. +func (cc *ClusterConnection) GetTaskAdmin() (*ra.TaskAdmin, error) { + ra, err := cc.GetRBDAdmin() + if err != nil { + return nil, err + } + + return ra.Task(), nil +} + // DisableDiscardOnZeroedWriteSame enables the // `rbd_discard_on_zeroed_write_same` option in the cluster connection, so that // writing zero blocks of data are actual writes on the OSDs (doing