Skip to content

Commit

Permalink
rbd: add function (cc *ClusterConnection) GetTaskAdmin()
Browse files Browse the repository at this point in the history
This function returns new go-ceph TaskAdmin to add
tasks on rbd volumes.

Signed-off-by: Rakshith R <rar@redhat.com>
  • Loading branch information
Rakshith-R committed Nov 18, 2021
1 parent 9645b3e commit 2ead05f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 2 additions & 4 deletions internal/rbd/rbd_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions internal/util/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 images.
func (cc *ClusterConnection) GetTaskAdmin() (*ra.TaskAdmin, error) {
rbdAdmin, err := cc.GetRBDAdmin()
if err != nil {
return nil, err
}

return rbdAdmin.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
Expand Down

0 comments on commit 2ead05f

Please sign in to comment.