Skip to content

Commit

Permalink
rbd: rename deleteImage() to Delete()
Browse files Browse the repository at this point in the history
Renaming the `Delete()` function makes it easier to implement the
upcoming `Volume` interface.

Signed-off-by: Niels de Vos <[email protected]>
  • Loading branch information
nixpanic authored and mergify[bot] committed Jul 8, 2024
1 parent 6b5ef1d commit 8d5e1aa
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion internal/rbd/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (rv *rbdVolume) createCloneFromImage(ctx context.Context, parentVol *rbdVol
defer func() {
if err != nil {
log.DebugLog(ctx, "Removing clone image %q", rv)
errDefer := rv.deleteImage(ctx)
errDefer := rv.Delete(ctx)
if errDefer != nil {
log.ErrorLog(ctx, "failed to delete clone image %q: %v", rv, errDefer)
}
Expand Down
12 changes: 6 additions & 6 deletions internal/rbd/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func (cs *ControllerServer) CreateVolume(
metadata := k8s.GetVolumeMetadata(req.GetParameters())
err = rbdVol.setAllMetadata(metadata)
if err != nil {
if deleteErr := rbdVol.deleteImage(ctx); deleteErr != nil {
if deleteErr := rbdVol.Delete(ctx); deleteErr != nil {
log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v", rbdVol, deleteErr)
}

Expand Down Expand Up @@ -621,7 +621,7 @@ func checkFlatten(ctx context.Context, rbdVol *rbdVolume, cr *util.Credentials)
if errors.Is(err, ErrFlattenInProgress) {
return status.Error(codes.Aborted, err.Error())
}
if errDefer := rbdVol.deleteImage(ctx); errDefer != nil {
if errDefer := rbdVol.Delete(ctx); errDefer != nil {
log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v", rbdVol, errDefer)

return status.Error(codes.Internal, err.Error())
Expand Down Expand Up @@ -681,7 +681,7 @@ func (cs *ControllerServer) createVolumeFromSnapshot(
defer func() {
if err != nil {
log.DebugLog(ctx, "Removing clone image %q", rbdVol)
errDefer := rbdVol.deleteImage(ctx)
errDefer := rbdVol.Delete(ctx)
if errDefer != nil {
log.ErrorLog(ctx, "failed to delete clone image %q: %v", rbdVol, errDefer)
}
Expand Down Expand Up @@ -764,7 +764,7 @@ func (cs *ControllerServer) createBackingImage(

defer func() {
if err != nil {
if deleteErr := rbdVol.deleteImage(ctx); deleteErr != nil {
if deleteErr := rbdVol.Delete(ctx); deleteErr != nil {
log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v", rbdVol, deleteErr)
}
}
Expand Down Expand Up @@ -1029,7 +1029,7 @@ func cleanupRBDImage(ctx context.Context,

// Deleting rbd image
log.DebugLog(ctx, "deleting image %s", rbdVol.RbdImageName)
if err = rbdVol.deleteImage(ctx); err != nil {
if err = rbdVol.Delete(ctx); err != nil {
log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v",
rbdVol, err)

Expand Down Expand Up @@ -1188,7 +1188,7 @@ func (cs *ControllerServer) CreateSnapshot(
defer func() {
if err != nil {
log.DebugLog(ctx, "Removing clone image %q", rbdVol)
errDefer := rbdVol.deleteImage(ctx)
errDefer := rbdVol.Delete(ctx)
if errDefer != nil {
log.ErrorLog(ctx, "failed to delete clone image %q: %v", rbdVol, errDefer)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/rbd/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func deleteMigratedVolume(ctx context.Context, parsedMigHandle *migrationVolID,
return err
}
defer rv.Destroy(ctx)
err = rv.deleteImage(ctx)
err = rv.Delete(ctx)
if err != nil {
log.ErrorLog(ctx, "failed to delete rbd image: %s, err: %v", rv, err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/rbd/rbd_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,8 @@ func (ri *rbdImage) ensureImageCleanup(ctx context.Context) error {
return nil
}

// deleteImage deletes a ceph image with provision and volume options.
func (ri *rbdImage) deleteImage(ctx context.Context) error {
// Delete deletes a ceph image with provision and volume options.
func (ri *rbdImage) Delete(ctx context.Context) error {
image := ri.RbdImageName

log.DebugLog(ctx, "rbd: delete %s using mon %s, pool %s", image, ri.Monitors, ri.Pool)
Expand Down Expand Up @@ -706,7 +706,7 @@ func (ri *rbdImage) trashRemoveImage(ctx context.Context) error {
// DeleteTempImage deletes the temporary image created for volume datasource.
func (rv *rbdVolume) DeleteTempImage(ctx context.Context) error {
tempClone := rv.generateTempClone()
err := tempClone.deleteImage(ctx)
err := tempClone.Delete(ctx)
if err != nil {
if errors.Is(err, ErrImageNotFound) {
return tempClone.ensureImageCleanup(ctx)
Expand Down
4 changes: 2 additions & 2 deletions internal/rbd/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func createRBDClone(
errSnap := parentVol.deleteSnapshot(ctx, snap)
if errSnap != nil {
log.ErrorLog(ctx, "failed to delete snapshot: %v", errSnap)
delErr := cloneRbdVol.deleteImage(ctx)
delErr := cloneRbdVol.Delete(ctx)
if delErr != nil {
log.ErrorLog(ctx, "failed to delete rbd image: %s with error: %v", cloneRbdVol, delErr)
}
Expand Down Expand Up @@ -85,7 +85,7 @@ func cleanUpSnapshot(
}

if rbdVol != nil {
err := rbdVol.deleteImage(ctx)
err := rbdVol.Delete(ctx)
if err != nil {
if !errors.Is(err, ErrImageNotFound) {
log.ErrorLog(ctx, "failed to delete rbd image %q with error: %v", rbdVol, err)
Expand Down

0 comments on commit 8d5e1aa

Please sign in to comment.