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 authored and nixpanic committed Jan 6, 2022
1 parent 753d916 commit ce21454
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
13 changes: 5 additions & 8 deletions internal/rbd/rbd_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,15 +676,13 @@ func (rv *rbdVolume) deleteImage(ctx context.Context) error {
// otherwise removes the image from trash.
func (rv *rbdVolume) trashRemoveImage(ctx context.Context) error {
// attempt to use Ceph manager based deletion support if available
log.DebugLog(ctx, "rbd: adding task to remove image %s with id %s from trash", rv, rv.ImageID)

ra, err := rv.conn.GetRBDAdmin()
ta, err := rv.conn.GetTaskAdmin()
if err != nil {
return err
}

log.DebugLog(ctx, "rbd: adding task to remove image %s with id %s from trash", rv, rv.ImageID)

ta := ra.Task()
_, err = ta.AddTrashRemove(admin.NewImageSpec(rv.Pool, rv.RadosNamespace, rv.ImageID))

rbdCephMgrSupported := isCephMgrSupported(ctx, rv.ClusterID, err)
Expand Down Expand Up @@ -828,14 +826,13 @@ func (rv *rbdVolume) flattenRbdImage(
return nil
}

ra, err := rv.conn.GetRBDAdmin()
log.DebugLog(ctx, "rbd: adding task to flatten image %q", rv)

ta, err := rv.conn.GetTaskAdmin()
if err != nil {
return err
}

log.DebugLog(ctx, "rbd: adding task to flatten image %s", rv)

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 @@ -131,6 +131,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 ce21454

Please sign in to comment.